Change CSS value when page has loaded?
Is it possible to change a value of a css style after the page has finished loading?
For example I need to change a division that is dis开发者_高级运维play:block
to display:none
after the page has finished loading?
Is this possible in jQuery and if so how do I implement it?
Checkout the ready()
event, and the css()
method.
Look at the list of possible selectors to see how to target your element.
$(document).ready(function () {
$('selectorForYourElement').css('display', 'none');
});
Edit:
To answer your question, you can either combine the selector with the:gt()
selector, or use the slice()
method (preferred).
$(document).ready(function () {
$('selectorForYourElement').slice(1).css('display', 'none');
});
Or
$(document).ready(function () {
$('selectorForYourElement:gt(0)').css('display', 'none');
});
$('selector').css({
display: 'none'
});
Give the block an id f.e. hideMe and do this in jQuery:
$(document).ready(function(){$("#hideMe").hide();});
精彩评论