单击后,我将移动一个 DIV,这很有效。但是 DIV 包含表单元素,并且在单击它们时也会发生操作,这是我不想要的。
我尝试向 DIV 的所有子级添加一个函数,该函数被调用,但父级 onclick 仍被触发。
$("#ControlPanel").click(function() {
switch ( $(this).css("top") )
{
case "0px":
$(this).animate({ top: "-100px" });
break;
case "-100px":
$(this).animate({ top: "0px" });
break;
}
});
$("#ControlPanel").children().click(function() { alert(1); return; });