I have a class called loading like this:
.loading {
display: none;
vertical-align: top;
margin: 0;
padding: 0;
background: url('../images/shared/loading_16x16.gif') center center no-repeat;
width: 16px;
height: 16px;
}
with following html snippet:
<div id="loading" class="loading"></div>
and my jQuery code (on document ready):
$.ajaxSetup({
beforeSend: function () {
$("#loading").show().children().show();
},
complete: function () {
$("#loading").hide().children().hide();
}
});
But show()
is not working at all. Even if I trigger it from the chrome developer window.
On the chrome developer window if I uncheck the display: none
from the loading class then the tag appears.
What's happening?
The default display value for most elements is block or inline . This panel contains a <div> element, which is hidden by default ( display: none ). It is styled with CSS, and we use JavaScript to show it (change it to ( display: block ).
The show() Method in jQuery is used to display the hidden and selected elements. Note: This method display the hidden elements which are using CSS display: none property. The elements are not visible whose visibility is hidden.
display: none; does not remove or in anyway affect an element's DOM representation.
I just figured out!
I fix it by doing this on my jQuery:
$.ajaxSetup({
beforeSend: function () {
$("#loading.loading").show();
},
complete: function () {
$("#loading.loading").hide();
}
});
Hope helps to some else :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With