jquery如何通过id修改css

首页 编程分享 JQUERY丨JS丨VUE 正文

醉折花枝作酒筹 转载 编程分享 2021-07-29 23:11:02

简介 在jquery中,可以使用“[att^=元素]”选择器匹配开头是某id的元素,然后使用css方法返回或设置匹配的元素的一个或多个样式属性,语法格式为“$(元素).css(属性,属性值)”。


本教程操作环境:windows7系统、jquery1.11.1版、Dell G3电脑。

<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>

设置所有匹配元素的指定 CSS 属性。

$(selector).css(name,value)

//设置所有ul的overflow属性为hidden。
$('[id^=foreignCurrencyTree_][id$=_ul]').css("overflow","hidden");
//设置所有li的display属性为inline
$('[id^=foreignCurrencyTree_][id$=_li]').css("display","inline");

【推荐学习:】

以上就是jquery如何通过id修改css的详细内容,更多请关注php中文网其它相关文章!

转载链接:http://www.php.cn//js-tutorial-480500.html


Tags:


本篇评论 —— 揽流光,涤眉霜,清露烈酒一口话苍茫。


    声明:参照站内规则,不文明言论将会删除,谢谢合作。


      最新评论




ABOUT ME

Blogger:袅袅牧童 | Arkin

Ido:PHP攻城狮

WeChat:nnmutong

Email:nnmutong@icloud.com

标签云