基于jQuery選擇器之表單對象屬性篩選選擇器的實(shí)例
更新時間:2017年09月19日 08:18:53 作者:喵嘻嘻
下面小編就為大家?guī)硪黄猨Query選擇器之表單對象屬性篩選選擇器實(shí)例。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <title></title> <link rel="stylesheet" href="imooc.css" rel="external nofollow" type="text/css"> <style> input { display: block; margin: 10px; padding: 10px; } </style> <script src="http://libs.baidu.com/jquery/1.9.1/jquery.js"></script> </head> <body> <h2>子元素篩選選擇器</h2> <h3>enabled、disabled</h3> <form> <input type="text" value="未設(shè)置disabled" /> <input type="text" value="設(shè)置disabled" disabled /> <input type="text" value="未設(shè)置disabled" /> </form> <script type="text/javascript"> //查找所有input所有可用的(未被禁用的元素)input元素。 $("input:enabled").css("border", "2px groove red"); </script> <script type="text/javascript"> //查找所有input所有不可用的(被禁用的元素)input元素。 $("input:disabled").css("border", "2px groove blue"); </script> <h3>checked、selected</h3> <form> <input type="checkbox" checked="checked"> <input type="checkbox"> <input type="radio" checked> <input type="radio"> <select name="garden" multiple="multiple"> <option>imooc</option> <option selected="selected">慕課網(wǎng)</option> <option>aaron</option> <option selected="selected">博客園</option> </select> </form> <script type="text/javascript"> //查找所有input所有勾選的元素(單選框,復(fù)選框) //移除input的checked屬性 $("input:checked").removeAttr('checked') </script> <script type="text/javascript"> //查找所有option元素中,有selected屬性被選中的選項 //移除option的selected屬性 $("option:selected").removeAttr('selected') </script> </body> </html>
注意:
在某些瀏覽器中,選擇器:checked可能會錯誤選取到<option>元素,所以保險起見換用選擇器input:checked,確保只會選取<input>元素
以上這篇jQuery選擇器之表單對象屬性篩選選擇器實(shí)例就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
簡短幾句jquery代碼的實(shí)現(xiàn)一個圖片向上滾動切換
短幾句jquery代碼實(shí)現(xiàn)一個圖片向上滾動切換,需要的朋友可以參考下。2011-09-09EasyUI折疊表格層次顯示detailview詳解及實(shí)例
這篇文章主要介紹了EasyUI折疊表格層次顯示detailview詳解及實(shí)例,非常不錯,具有參考借鑒價值,需要的朋友參考下吧2016-12-12jquery插件jquery.nicescroll實(shí)現(xiàn)圖片無滾動條左右拖拽的方法
這篇文章主要介紹了jquery插件jquery.nicescroll實(shí)現(xiàn)圖片無滾動條左右拖拽的方法,實(shí)例分析了jquery.nicescroll插件實(shí)現(xiàn)圖片拖拽效果的方法,需要的朋友可以參考下2015-08-08jq實(shí)現(xiàn)左滑顯示刪除按鈕,點(diǎn)擊刪除實(shí)現(xiàn)刪除數(shù)據(jù)功能(推薦)
下面小編就為大家?guī)硪黄猨q實(shí)現(xiàn)左滑顯示刪除按鈕,點(diǎn)擊刪除實(shí)現(xiàn)刪除數(shù)據(jù)功能(推薦)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-08-08