jquery基本選取器

來源:互聯網
上載者:User

標籤:

 

*:(通配選取器)除非被它自己使用,否則 * 選取器或通用選取器,其速度是極其慢的。

eg:

$("*").css("border","3px solid red") 將頁面中所有元素都加上邊線。

     $("#wrap2").find("*").css("border","3px solid red");  使用通配,匹配某個標籤中的所有元素,將元素添加邊框樣式

 

class: 一個用來尋找的類名。一個元素可以有多個類;其中只有一個必須匹配。

eg:

$(".content1").css("border","3px solid red");
$(".content2").css("border","1px solid blue");

 

element: 一個用來搜尋的元素。 指DOM節點的標籤名

eg:

$("div").css("border","2px solid green");

 

id: 一個用來尋找的ID,即元素的id屬性

eg:

$("#borderstyle").css("color","pink");  設定字型顏色,當有兩個相同的ID時匹配第一個元素

 

任何元素匹配選取器:  將每一個選取器匹配到的元素合并後一起返回。

eg:

$("p,.content2,#borderstyle").css("border","1px solid orange");

jquery基本選取器

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.