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.
我有一个 ASP.NET 下拉列表,当用户单击展开箭头以显示选项列表时,它需要执行一些 javascript,但当前选择一个选项也会触发 onclick 事件,这是我不想要的。
有没有办法在不使用某种标志的情况下做到这一点?
您需要防止该嵌套元素的点击冒泡
thatElementOnclickFunction = function (evt) { evt = evt || window.event; evt.cancelBubble = true; if(evt.stopPropagation) evt.stopPropagation(); }