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.
我在水平面板中有一个按钮。按钮和面板都有点击处理程序。
当我单击按钮时,我只希望按钮单击处理程序工作而不是面板之一,但它会触发两者。
如何避免触发面板点击处理程序?
只需调用event.stopPropagation()您的点击处理程序。有关示例,请参见此处的答案。
event.stopPropagation()