$("#sava").removeAttr("onClick"); 
$("#sava").unbind( "click" )
$("#cu_save").click( function() {
   alert("OOOO");
});<input type="button" value="新增" id="save" name="cu_save" class="anniu_1" onClick="toAdd();" />我用了两种方法了还是不能清除,还是进入了toAdd()方法
可能是什么原因呢?????

解决方案 »

  1.   

    $("#sava").removeAttr("onClick"); 
    $("#sava").unbind( "click" )$("#save").removeAttr("onclick"); 
    $("#save").unbind( "click" )
      

  2.   

    你把 js 和 html换个位置把 js拿到下面来
    <input type="button" value="新增" id="save" name="cu_save" class="anniu_1" onClick="toAdd();" />$("#sava").removeAttr("onClick"); 
    $("#sava").unbind( "click" )
    $("#cu_save").click( function() {
      alert("OOOO");
    });
      

  3.   

    还是不行   可恶的是他居然先进了 toAdd() 然后又弹出 对话框OOO
      

  4.   

    $("#sava").removeAttr("onClick");  
    $("#sava").unbind( "click" )
    楼主这2句是写在画面的ONLOAD方法里的吗?
      

  5.   

    JQuery只能移除动态产生的事件,不能移除直接在HTML给出(静态写入)的事件,应该是这样,验证如下:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>JQuery</title>
    </head>
    <style type="text/css"> 
    body,td,div,input,fieldset,legend{font-family:Verdana; font-size:12px; color:#333333; font-weight:normal;}
    .title01{font-weight:bold; font-family:Verdana; font-size:14px;}
    .title02{font-weight:bold; font-family:Verdana; font-size:12px; color:#0000FF; display:block;}
    a:link,a:visited{font-family:Verdana; font-size:12px; color:#330099; font-weight:normal; text-decoration:none;}
    a:hover,a:active{font-family:Verdana; font-size:12px; color:#FF6600; font-weight:normal; }
    </style><script language="javascript" type="text/javascript" src="jquery-1.4.2.min.js"></script>
    <script language="javascript" type="text/javascript">
    function addEvt(){
    $("#div01").bind("click",function(){alert($(this).html());});
    }function releaseEvt(){
    $("#div01").unbind("click");
    }function display(){
    alert("static function on object");
    }
    </script>
    <body>
    <p><br><div id="div01" onClick="javascript:display();">div content 01</div></p>
    <a href="javascript:addEvt();">增加事件到DIV</a>&nbsp;&nbsp;<a href="javascript:releaseEvt();">释放DIV的click事件</a>
    </body>
    </html>
      

  6.   

    直接将$("#sava").onclick="";
    如果还想继续用onclick里面的内容就在相应的条件下再写一个
    $("#sava").onclick=function(){
       原来的onclick时间的处理方法
    }
    方法有点笨,但是很实用!
      

  7.   

     估计shenzhenNBA   说得对
      我默认调用的是toAdd
    怎么写 a 
      

  8.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>JQuery</title>
    </head>
    <style type="text/css"> 
    body,td,div,input,fieldset,legend{font-family:Verdana; font-size:12px; color:#333333; font-weight:normal;}
    .title01{font-weight:bold; font-family:Verdana; font-size:14px;}
    .title02{font-weight:bold; font-family:Verdana; font-size:12px; color:#0000FF; display:block;}
    a:link,a:visited{font-family:Verdana; font-size:12px; color:#330099; font-weight:normal; text-decoration:none;}
    a:hover,a:active{font-family:Verdana; font-size:12px; color:#FF6600; font-weight:normal; }
    </style><script language="javascript" type="text/javascript" src="jquery-1.4.2.min.js"></script>
    <script language="javascript" type="text/javascript">
    function addEvt(){
    $("#div01").bind("click",display);
    }function releaseEvt(){
    $("#div01").unbind("click");
    }function display(){
    alert("static function on object");
    }
    </script>
    window.onload=function(){
    addEvt();
    }

    <body>
    <p><br><div id="div01">div content 01</div></p>
    <a href="javascript:addEvt();">增加事件到DIV</a>&nbsp;&nbsp;<a href="javascript:releaseEvt();">释放DIV的click事件</a>
    </body>
    </html>
      

  9.   

    哥哥们啊   郁闷死了 $("#sava").removeAttr("onClick");  改成小写 就ok
    $("#sava").removeAttr("onclick");  
      

  10.   

    当作属性可以移除,学习了... :)上面有一点位置写错了,
    window.onload=function(){
    addEvt();
    }
    写在
    </script>
    前面. :)