Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在学习 JS,我想知道 - 为什么这不起作用?
$(function(){ $('#mydiv').bind('click', $('#myanotherdiv').remove); });
$('#mydiv').bind('click', $('#myanotherdiv').remove);
第二个参数应该是事件的处理程序
$('#mydiv').bind('click', function() { $('#myanotherdiv').remove() });\
.remove是一种方法而不是属性
所以应该写成.remove()
.remove()