页面加载后更改CSS值? [英] Change CSS value when page has loaded?
本文介绍了页面加载后更改CSS值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
页面加载完成后是否可以更改css样式的值?
Is it possible to change a value of a css style after the page has finished loading?
例如我需要更改<$ c $的分区c>显示:阻止到显示:无
页面加载完毕后?
For example I need to change a division that is display:block
to display:none
after the page has finished loading?
这在jQuery中是否可行,如果可以,我该如何实现呢?
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');
});
编辑:
要回答您的问题,您可以将选择器与:gt()
选择器,或使用 slice()
方法(首选)。
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');
});
或
$(document).ready(function () {
$('selectorForYourElement:gt(0)').css('display', 'none');
});
这篇关于页面加载后更改CSS值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文