作者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
1F:→ gaekeamql: 因为有用途需要把onclick 清除 再恢复 id 可以数字 01/29 09:02
2F:→ s25g5d4:你可以做bind/unbind 01/29 09:18