jQuery學習筆記 07

來源:互聯網
上載者:User

jQuery學習筆記:
$(document).ready( function()
{
 $("#TestTable tr").not(":first").css("color", "blue");
});

把表中除第一行以外,其它行設為藍色字型。

知識點:
排除某些內容用not,裡面的參數可以假設為前面的參數加上它。也可以用這種方式:
 $("#TestTable tr").not($("#TestTable tr:first")
其它的幾種錯誤表達:
 $("#TestTable tr").not("first")
 $("#TestTable tr").not("tr:first")

如果不是排除,而是過濾,可以用filter。
 $("#TestTable tr").filter(":odd").css("color", "blue");

前面我們說增加樣式及移除樣式用addClass及removeClass,但這些方法前提是要在樣式表中命名好。而css則是可以隨時增加各種樣式,它有這幾種表達方式:
css(key, value):就是我們上面用的方式
css(properties):用一個串來表示,如css({fontWeight:"bold", fontSize:"15pt"});
注意雙引號,並且使用的是script的style的格式,而不是HTML的style格式(font-weight、font-size),因此大小寫也要注意。
還可以一層套一層,如css("color", "blue").css({fontWeight:"bold"});

如果要取某個樣式的值,可以用這種形式:css("color")

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.