Jquery——選取器2

來源:互聯網
上載者:User

標籤:att   ul li   mat   定義   UI   選取器   ide   closed   ebe   

1 $("ul li:eq(3)")
選取器

列表中等於3的元素,0開始(第四個)

1 $("ul li:lt(2)")
選取器

列表中小於2的元素,0開始

1 $("ul li:gt(2)")
選取器

列表中大於2的元素,0開始。

1 $("[name^=‘user‘]")
選取器

name中以user開頭的

1 $("[name$=‘ge‘]")
選取器

name中以ge結尾的

1 $("[name*=‘na‘]")
選取器

name中包含na的

1 $("[name*=‘name‘][id *= ‘username‘]")
選取器(多重)

name中包含name,且id中包含username的

 1 $("input[reg]").each(function(){ 2         var val = $(this).val(); 3         var tip = $(this).attr("tip"); 4         var reg = $(this).attr("reg"); 5         var regexp = new RegExp(reg); 6         if(!regexp.test(val)){ 7             alert(tip) 8         } 9     })10 11 12 <input   type = "text"  name = "username" id = "username" reg = "^\w{1,12}$" tip = "Name Input format does not conform to the requirements"/>13 <input   type = "password" name = "password" id = "password" reg = "^\w{1,12}$" tip = "PassWord Input format does not conform to the requirements"/>14 15 <input   type = "text" name = "email" id = "email" reg = "^\w*\@\w*\.\w*$" tip = "Email Input format does not conform to the requirements"/>
自訂選取器

自訂選取器,選擇input中含有reg屬性的。

利用Regex進行條件式篩選。對input中的val進行判斷。

Jquery——選取器2

聯繫我們

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