Joh*_*ith 12
这是完美的解决方案.(至少对于我来说.)
$(document).on('click', 'a#button', function(){
$(this).after('<span> hello</span>');
$('span').fadeOut(1000);
});
$('a#toggle').toggle(
function(){
$(this).text('rebind');
$('a#button').on('click.disabled', false);
},
function(){
$(this).text('unbind');
$('a#button').off('click.disabled');
}
);
Run Code Online (Sandbox Code Playgroud)
".on()"做到了.注意:像在第一行看到的那样绑定事件非常重要!它不适用于.click()或......!
看文档!
请享用!