Home > Article > Web Front-end > How to modify css by id in jquery
In jquery, you can use the "[att^=element]" selector to match elements starting with a certain id, and then use the css method to return or set one or more style attributes of the matched element, syntax format is "$(element).css(attribute, attribute value)".
The operating environment of this tutorial: Windows 7 system, jquery version 1.11.1, Dell G3 computer.
<ul id="foreignCurrencyTree_1_ul"> <li id="foreignCurrencyTree_11_li">111111</li> <li id="foreignCurrencyTree_12_li">222222</li> <li id="foreignCurrencyTree_13_li">333333</li> </ul> <ul id="foreignCurrencyTree_2_ul"> <li id="foreignCurrencyTree_21_li">111111</li> <li id="foreignCurrencyTree_22_li">222222</li> <li id="foreignCurrencyTree_23_li">333333</li> </ul>
# Sets the specified CSS property for all matching elements.
$(selector).css(name,value)
//设置所有ul的overflow属性为hidden。 $('[id^=foreignCurrencyTree_][id$=_ul]').css("overflow","hidden"); //设置所有li的display属性为inline $('[id^=foreignCurrencyTree_][id$=_li]').css("display","inline");
[Recommended learning: javascript advanced tutorial]
The above is the detailed content of How to modify css by id in jquery. For more information, please follow other related articles on the PHP Chinese website!