1. 程式人生 > >href與onclick()分別添加this對象

href與onclick()分別添加this對象

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對象