更新时间:2023-12-04 11:52:22
stopPropagation
阻止当前事件在捕获和冒泡阶段进一步传播.
preventDefault
阻止浏览器对该事件进行的默认操作.
preventDefault
$("#but").click(function (event) {event.preventDefault()})$("#foo").click(function () {alert("父点击事件被触发!")})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><div id="foo"><button id="but">button</button>