jQuery動態設定樣式(style、css)

來源:互聯網
上載者:User

一、jQuery設定css樣式

<div style="background-color:#ffffff;padding-left:10px;">測試jQuery動態擷取padding-left</div>

1、用css()方法返回元素的樣式屬性

$("div").css("padding-left"));

2、用css()設定樣式

$("div").css("color","yellow");

3、設定多個樣式

$("div").css({"background-color":"yellow","font-size":"200%"});
var css = {    background-color: '#EEE',    height: '500px',    margin: '10px',    padding: '2px 5px'};$("div").css(css);














相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.