CSS:隐藏对象是否可点击? [英] CSS: Is a hidden object clickable?
本文介绍了CSS:隐藏对象是否可点击?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果设置为 hidden
的HTML对象样式的 visibility
属性是否仍可点击?
当显示
属性设置为 none
对象甚至不是DOM树的一部分,所以这不是问题。但我想知道一个 hidden
对象是否仍然响应鼠标事件。
解决方案
使用 display:none
>仍然是DOM的一部分。
对于 visibility:hidden
的元素的点击,事件
jsFiddle 。
$('div')。click(function(){alert('Hello')});
div {width:100%;高度:100%; visibility:hidden; }
< div> abc< / div> code>
If the visibility
property of the style of an HTML object in set to hidden
, is it still clickable ?
When the display
property is set to none
, the object is not even part of the DOM tree, so that is not a problem. But I was wondering if a hidden
object still responds to mouse events.
解决方案
With display: none
it is still part of the DOM. It just isn't rendered in the viewport.
As for clicks on elements with visibility: hidden
, the events are not fired.
$('div').click(function() {
alert('Hello')
});
div {
width: 100%;
height: 100%;
visibility: hidden;
}
<div>abc</div>
这篇关于CSS:隐藏对象是否可点击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文