Javascript - Does A Click Event Fire On An Element If It's Not Visible?
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. ) and disable the
Solution 1:
No it won't fire when visibility:hidden
, here is proof :)
JS
$('div').click(function() {
alert('');
});
CSS
div {
background-color:red;
width:100px;
height:100px;
}
.hidden {
visibility:hidden
}
Solution 2:
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.
Post a Comment for "Javascript - Does A Click Event Fire On An Element If It's Not Visible?"