jQuery選擇器之表單元素選擇器詳解
更新時間:2017年09月19日 12:00:13 作者:喵嘻嘻
這篇文章主要為大家詳細介紹了jQuery選擇器之表單元素選擇器的相關(guān)資料,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了表單元素選擇器,供大家參考,具體內(nèi)容如下
<!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>input、text、password、radio、checkbox</h3> <h3>submit、image、reset、button、file</h3> <div class="left first-div"> <form> <input type="text" value="text類型"/> <input type="password" value="password"/> <input type="radio"/> <input type="checkbox"/> <input type="submit" /> <input type="image" /> <input type="reset" /> <input type="button" value="Button" /> <input type="file" /> </form> </div> <script type="text/javascript"> //查找所有 input, textarea, select 和 button 元素 //:input 選擇器基本上選擇所有表單控件 $(":input").css("border", "1px groove red"); </script> <script type="text/javascript"> //匹配所有input元素中類型為text的input元素 $(":text").css("background", "#A2CD5A"); </script> <script type="text/javascript"> //匹配所有input元素中類型為password的input元素 $(":password").css("background", "yellow"); </script> <script type="text/javascript"> //匹配所有input元素中的單選按鈕,并選中 $(":radio").attr('checked','true'); </script> <script type="text/javascript"> //匹配所有input元素中的復(fù)選按鈕,并選中 $(":checkbox").attr('checked','true'); </script> <script type="text/javascript"> //匹配所有input元素中的提交的按鈕,修改背景顏色 $(":submit").css("background", "#C6E2FF"); </script> <script type="text/javascript"> //匹配所有input元素中的圖像類型的元素,修改背景顏色 $(":image").css("background", "#F4A460"); </script> <script type="text/javascript"> //匹配所有input元素中類型為按鈕的元素 $(":button").css("background", "red"); </script> <script type="text/javascript"> //匹配所有input元素中類型為file的元素 $(":file").css("background", "#CD1076"); </script> </body> </html>
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
jQuery zclip插件實現(xiàn)跨瀏覽器復(fù)制功能
這篇文章主要介紹了jQuery zclip插件實現(xiàn)跨瀏覽器復(fù)制功能的方法,以及在實現(xiàn)過程中遇到的問題,感興趣的小伙伴們可以參考一下2015-11-11