Re: [問題] jquery attr onclick IE7 & 8

看板Ajax作者 (System hacked)時間14年前 (2011/01/29 02:39), 編輯推噓0(002)
留言2則, 2人參與, 最新討論串2/7 (看更多)
※ 引述《gaekeamql (芋頭)》之銘言: : 問一下 : <input type="button" id=1 onclick="alert('001122');" value="alert"> : <input type="button" onclick="$('#1').attr('onclick','');" value="C"> : <input type="button" onclick="$('#1').attr('onclick','alert(\'334455\');');" : value="RE"> : 此動作在OPREA OK 但是在IE 清除候 再輸入 : $('#1').attr('onclick','alert(\'001122\');'); 卻是沒反應的 : 但是 是有把 oncilck="alert('334455');" 寫進去 但是不會動作 不確定 id 是否可以為數字開頭,另外一般配合 jQuery 是用: $('#id1').click(function(){ alert('334455'); }); 或是: $('#id1').bind('click', function(){ alert('334455'); }); 不確定你是從那邊學來的用法... -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 210.242.135.97

01/29 09:02, , 1F
因為有用途需要把onclick 清除 再恢復 id 可以數字
01/29 09:02, 1F

01/29 09:18, , 2F
你可以做bind/unbind
01/29 09:18, 2F
文章代碼(AID): #1DGmrn1W (Ajax)
文章代碼(AID): #1DGmrn1W (Ajax)