href与onclick()分别添加this对象

<!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>
原文地址:https://www.cnblogs.com/lm3306/p/7376624.html