juqery 學(xué)習(xí)之三 選擇器 子元素與表單
:nth-child(index/even/odd/equation)
可以使用:
nth-child(even)
:nth-child(odd)
:nth-child(3n)
:nth-child(2)
:nth-child(3n+1)
:nth-child(3n+2)
返回值
Array<Element>
參數(shù)
index (Number) : 要匹配元素的序號(hào),從1開(kāi)始
示例
在每個(gè) ul 查找第 2 個(gè)li
HTML 代碼:
<li>John</li>
<li>Karl</li>
<li>Brandon</li>
</ul>
<ul>
<li>Glen</li>
<li>Tane</li>
<li>Ralph</li>
</ul>
jQuery 代碼:
結(jié)果:
--------------------------------------------------------------------------------
:first-child
返回值
Array<Element>
示例
在每個(gè) ul 中查找第一個(gè) li
HTML 代碼:
<li>John</li>
<li>Karl</li>
<li>Brandon</li>
</ul>
<ul>
<li>Glen</li>
<li>Tane</li>
<li>Ralph</li>
</ul>
jQuery 代碼:
結(jié)果:
--------------------------------------------------------------------------------
:last-child
返回值
Array<Element>
示例
在每個(gè) ul 中查找最后一個(gè) li
HTML 代碼:
<li>John</li>
<li>Karl</li>
<li>Brandon</li>
</ul>
<ul>
<li>Glen</li>
<li>Tane</li>
<li>Ralph</li>
</ul>
jQuery 代碼:
結(jié)果:
--------------------------------------------------------------------------------
:only-child
返回值
Array<Element>
示例
在 ul 中查找是唯一子元素的 li
HTML 代碼:
<li>John</li>
<li>Karl</li>
<li>Brandon</li>
</ul>
<ul>
<li>Glen</li>
jQuery 代碼:
結(jié)果:
--------------------------------------------------------------------------------
:input
返回值
Array<Element>
示例
查找所有的input元素
HTML 代碼:
<input type="text" />
<input type="checkbox" />
<input type="radio" />
<input type="image" />
<input type="file" />
<input type="submit" />
<input type="reset" />
<input type="password" />
<input type="button" />
<select><option/></select>
<textarea></textarea>
<button></button>
</form>
jQuery 代碼:
結(jié)果:
--------------------------------------------------------------------------------
:text
返回值
Array<Element>
示例
查找所有文本框
HTML 代碼:
<input type="text" />
<input type="checkbox" />
<input type="radio" />
<input type="image" />
<input type="file" />
<input type="submit" />
<input type="reset" />
<input type="password" />
<input type="button" />
<select><option/></select>
<textarea></textarea>
<button></button>
</form>
jQuery 代碼:
結(jié)果:
--------------------------------------------------------------------------------
:password
返回值
Array<Element>
示例
查找所有密碼框
HTML 代碼:
<input type="text" />
<input type="checkbox" />
<input type="radio" />
<input type="image" />
<input type="file" />
<input type="submit" />
<input type="reset" />
<input type="password" />
<input type="button" />
<select><option/></select>
<textarea></textarea>
<button></button>
</form>
jQuery 代碼:
結(jié)果:
--------------------------------------------------------------------------------
:radio
返回值
Array<Element>
示例
查找所有單選按鈕
HTML 代碼:
<input type="text" />
<input type="checkbox" />
<input type="radio" />
<input type="image" />
<input type="file" />
<input type="submit" />
<input type="reset" />
<input type="password" />
<input type="button" />
<select><option/></select>
<textarea></textarea>
<button></button>
</form>
jQuery 代碼:
結(jié)果:
--------------------------------------------------------------------------------
:submit
返回值
Array<Element>
示例
查找所有提交按鈕
HTML 代碼:
<input type="text" />
<input type="checkbox" />
<input type="radio" />
<input type="image" />
<input type="file" />
<input type="submit" />
<input type="reset" />
<input type="password" />
<input type="button" />
<select><option/></select>
<textarea></textarea>
<button></button>
</form>
jQuery 代碼:
結(jié)果:
其他的一些 都是一樣的道理:image ,:reset,:button,:file,:hidden !@#@!%$%
相關(guān)文章
jQuery實(shí)現(xiàn)異步獲取json數(shù)據(jù)的2種方式
這篇文章主要介紹了jQuery實(shí)現(xiàn)異步獲取json數(shù)據(jù)的2種方式,主要講述了$.getJSON方法與$.ajax方法,非常實(shí)用,需要的朋友可以參考下2014-08-08jQuery實(shí)現(xiàn)錨點(diǎn)向下平滑滾動(dòng)特效示例
下面小編就為大家?guī)?lái)一篇jQuery實(shí)現(xiàn)錨點(diǎn)向下平滑滾動(dòng)特效示例。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-08-08使用jQuery給input標(biāo)簽設(shè)置默認(rèn)值
這篇文章主要介紹使用jQuery給input標(biāo)簽設(shè)置默認(rèn)值的方法,實(shí)例講解,非常實(shí)用,需要的朋友可以參考下。2016-06-06jQuery中借助deferred來(lái)請(qǐng)求及判斷AJAX加載的實(shí)例講解
deferred對(duì)象的延遲功能對(duì)jQuery的ajax操作是一個(gè)很大的幫助,尤其是回調(diào)控制,下面我們就來(lái)看一下對(duì)jQuery中借助deferred來(lái)請(qǐng)求及判斷AJAX加載的實(shí)例講解2016-05-05jQuery基于ajax實(shí)現(xiàn)帶動(dòng)畫(huà)效果無(wú)刷新柱狀圖投票代碼
這篇文章主要介紹了jQuery基于ajax實(shí)現(xiàn)帶動(dòng)畫(huà)效果無(wú)刷新柱狀圖投票代碼,通過(guò)使用jquery動(dòng)態(tài)操作頁(yè)面元素樣式屬性實(shí)現(xiàn)柱狀圖投票效果,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2015-08-08JQuery實(shí)現(xiàn)DIV其他動(dòng)畫(huà)效果的簡(jiǎn)單實(shí)例
下面小編就為大家?guī)?lái)一篇JQuery實(shí)現(xiàn)DIV其他動(dòng)畫(huà)效果的簡(jiǎn)單實(shí)例。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2016-09-09jQuery EasyUI 中文API Button使用實(shí)例
jQuery EasyUI 中文API Button使用小結(jié),需要的朋友可以參考下。2010-04-04jQuery zTree樹(shù)插件動(dòng)態(tài)加載實(shí)例代碼
這篇文章主要介紹了jQuery zTree樹(shù)插件動(dòng)態(tài)加載效果的實(shí)例代碼,需要的朋友可以參考下2017-05-05