开发者

Change CSS value when page has loaded?

开发者 https://www.devze.com 2023-04-06 22:25 出处:网络
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 fi

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();});
0

精彩评论

暂无评论...
验证码 换一张
取 消