我有两个UL标签 here is jsbin link的jQuery的append()元素点击事件
和我的剧本是
$("#to-do li").click(function(){
alert("I'm to-do li");
$(this).appendTo("#done");
});
$("#done li").on('click', function(){
// this event is not fired
alert("I'm done li");
$(this).appendTo("#to-do");
});
和要求是对的“待办事项丽”点击,就应该追加到“完成李“,反之亦然。
第一个功能正常工作正常。但第二个并没有被解雇。 点击“#done li”,再次调用第一个函数。 请帮忙..
1)为什么(“#to-do li”)事件在点击$(“#done li”)时触发。 2)如何实现这一目标
通常,使用事件代理,所以看到阿伦的回答。一些阅读:http://jqfundamentals.com/chapter/events –
为什么负面的标记?这个问题有什么不对? – Chandu
我觉得因为这个问题每周要问百次 –