a链接点击事件失效的方法

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <a onclick="clickk()">jiayo</a>
         <input type="button" value="点击" />
    </body>
    <script type="text/javascript" src="../JS/ectouch/img/jquery.js" ></script>
    
    <script>
         function clickk(){
             alert(1);
         }
        
        $("input").click(function(e){
             $("a").css("color","#eee");
             $("a").removeAttr("onclick","");

        })
    </script>
</html>

注意:

1:a 链接点击事件要写在标签里,(不要单独写a事件的click事件否则无法生效),其它元素触发事件时 移除a链接的onclick事件即可

2:onclick事件属于js事件,不可放在jq事件中

猜你喜欢

转载自blog.csdn.net/journeynana/article/details/81776409
今日推荐