admin管理员组文章数量:1022834
If you change the visibility of an element visibility: hidden
, will a click event still fire if the user clicks it?
I want to "hide" an element (i.e. <span>
) and disable the click event from firing, but retain is position in the normal flow of the document. So display: none;
won't work since it removes the document from the normal flow, but was wondering what are my other options via CSS without actually handling the click event and using preventDefault()?
If you change the visibility of an element visibility: hidden
, will a click event still fire if the user clicks it?
I want to "hide" an element (i.e. <span>
) and disable the click event from firing, but retain is position in the normal flow of the document. So display: none;
won't work since it removes the document from the normal flow, but was wondering what are my other options via CSS without actually handling the click event and using preventDefault()?
- Did you try it out? What happened? – epascarello Commented Mar 29, 2013 at 17:48
2 Answers
Reset to default 5No it won't fire when visibility:hidden
, here is proof :)
jsFiddle
JS
$('div').click(function() {
alert('');
});
CSS
div {
background-color:red;
width:100px;
height:100px;
}
.hidden {
visibility:hidden
}
Yes visibility hidden disables the click event.
To test just right click a clickable element on this page with a web-kit browser, apply a style of visibility: hidden
and you will be unable to click it.
If you change the visibility of an element visibility: hidden
, will a click event still fire if the user clicks it?
I want to "hide" an element (i.e. <span>
) and disable the click event from firing, but retain is position in the normal flow of the document. So display: none;
won't work since it removes the document from the normal flow, but was wondering what are my other options via CSS without actually handling the click event and using preventDefault()?
If you change the visibility of an element visibility: hidden
, will a click event still fire if the user clicks it?
I want to "hide" an element (i.e. <span>
) and disable the click event from firing, but retain is position in the normal flow of the document. So display: none;
won't work since it removes the document from the normal flow, but was wondering what are my other options via CSS without actually handling the click event and using preventDefault()?
- Did you try it out? What happened? – epascarello Commented Mar 29, 2013 at 17:48
2 Answers
Reset to default 5No it won't fire when visibility:hidden
, here is proof :)
jsFiddle
JS
$('div').click(function() {
alert('');
});
CSS
div {
background-color:red;
width:100px;
height:100px;
}
.hidden {
visibility:hidden
}
Yes visibility hidden disables the click event.
To test just right click a clickable element on this page with a web-kit browser, apply a style of visibility: hidden
and you will be unable to click it.
本文标签: cssjavascriptdoes a click event fire on an element if it39s not visibleStack Overflow
版权声明:本文标题:css - javascript - does a click event fire on an element if it's not visible? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745568980a2156620.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论