href與onclick()分別添加this對象
阿新 • • 發佈:2017-08-17
itl round color title undefined obj script clas 對象
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <div><a href="javascript:go_a1(this)" id="a1">a1</a></div> <div><a href="" id="a1" onclick="go_a2(this)">a2</a></div> <script type="text/javascript"> function go_a1(obj) { alert("點擊a1----"+obj.innerHTML);//點擊a1----undefined } function go_a2(obj) { alert("點擊a2----"+obj.innerHTML);//點擊a2----a2 } </script> </body> </html>
href與onclick()分別添加this對象