jquery搜尋和設定元素

來源:互聯網
上載者:User

標籤:

文章摘自:http://blog.chinaunix.net/uid-26957269-id-3530689.html 搜尋元素 1、利用標籤名擷取元素 $("標籤名")
2、通過ID擷取元素 $("#id_name")
3、通過 類名擷取元素 $(".className")
4、一次性擷取多個元素 $("元素名, 元素名, 元素名 ....")
5、通過指定層次關係擷取元素 $("祖先    子孫") $("父  >  子") $("前  +  後") $("兄  ~  弟")
6、根據元素的屬性值擷取元素 [attribute] [attribute = value] [attribute != value] [attribute ^= value] [attribute $= value] [attribute *= value]
7、通過過濾器擷取元素 $("元素名:過濾器")
過濾器列表 :first :last :not(filter) :even :odd :eq(index) :lt(index) :gt(index) :header :animated :contains(text) :empty :has(selector) :parent【註:這個是擷取非空元素不是父元素】
8、擷取表單元素 $(":表單過濾器名")
擷取表單元素的方法 :input :text :password :radio :checkbox :submit :image :reset :button :file 【註:表單標籤也是標籤,同樣可以利用標籤名擷取,不過有些標籤類型多樣可以加過濾器加以區分。如:$("input:text")】
9、通過過濾器擷取表單元素 :enable    擷取可輸入狀態的元素 :disabled    擷取不可輸入狀態的元素 :checked    擷取選中元素的元素 :selected    擷取下拉框中選中狀態的元素
10、從集合元素中通過指定序號擷取元素 $("元素名").eq(index)
11、擷取指定條件一致的元素 $("元素名").filter(expr)
12、擷取指定範圍的元素 $("元素名").slice(start,[end])
13、擷取與條件運算式一致的元素 $("元素名").is(expr)
14、擷取元素的下一個元素 $("元素名").next([expr])
15、擷取元素的前一個元素 $("元素名").prev([expr])
16、擷取元素的父元素 $("元素名").parent([expr])
17、擷取元素的子項目 $("元素名").children([expr])

設定元素1、在元素內部追加內容 $("元素名").append(content)
2、在元素中的不同位置追加內容$("元素名").appendTo(content)
3、在元素的開始位置追加內容$("元素名").prepend(content)
4、在不同元素的開始位置追加元素$("元素名").prependTo(content)
5、在元素後追加兄弟元素$("元素名").after(content)
6、在元素前追加兄弟元素$("元素名").before(content)
7、用指定結構的元素包含元素$("元素名").wrap(html)
8、用指定結構的元素包含多個元素的集合$("元素名").wrapAll(html)
9、用指定標籤包含子項目$("元素名").wrapInner(html)
10、替換元素$("元素名").replaceWith(content)$("元素名").replaceAll(selector)
11、刪除元素$("元素名").empty()$("元素名").remove([expr])
12、複製元素$("元素名").clone()$("元素名").clone(true)

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.