我的问题是我有这个盒子,也就是容器。在该容器内有用户可以单击的框。
为了在视觉上帮助用户,我制作了带有灰色渐变颜色的叠加框 告诉他们可以使用这里的盒子。
但我的问题是点击事件发生在覆盖框后面的框上。
那么有什么方法可以忽略元素的 .click()
并使用下一个目标吗?
最佳答案
您可以使用 CSS pointer-events
属性:
The CSS property
pointer-events
allows authors to control under what circumstances (if any) a particular graphic element can become the target of mouse events.
#element {
pointer-events: none;
}
或者您可以触发
click
事件:
$('#box').click(function(){
$('#target').trigger('click')
})
关于javascript - jQuery - 在后面的元素上触发点击事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11914068/