作者DarkKiller (System hacked)
看板Ajax
標題Re: [問題] jquery attr onclick IE7 & 8
時間Sat Jan 29 02:39:42 2011
※ 引述《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
→ gaekeamql: 因為有用途需要把onclick 清除 再恢復 id 可以數字 01/29 09:02
→ s25g5d4:你可以做bind/unbind 01/29 09:18