天天看点

jquery选择器之表单选择\表单对象属性

  :input 匹配所有input标签

  :text 匹配所有单行文本框

  :password 匹配所有密码框

  :radio  匹配所有单选扭

  :checkbox 匹配所有复选框

  :image 匹配所有图像域

  :reset 匹配所有重置按扭

  :button 匹配所有按扭

  :file 匹配所有文件域

  示例代码

<!DOCTYPE html>
<html >
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
    <form>
    <input type="button" value="Input Button"/>
    <input type="checkbox" />

    <input type="file" />
    <input type="hidden" />
    <input type="image" />

    <input type="password" />
    <input type="radio" />
    <input type="reset" />

    <input type="submit" />
    <input type="text" value="text" />
    <select><option>Option</option></select>

    <textarea></textarea>
    <button>Button</button>
</form>

    <script src="jquery-3.1.0.js"></script>
    <script type="text/javascript">
//        匹配所有input标签
        $(":input")
//        匹配所有input标签中类型为text的元素
        $(":text")
//        匹配所有input标签中类型为password的元素
        $(":password")
        匹配所有input标签中类型为radio的元素
        $(":radio")
        $(":checkbox")
        $(":submit")
        $(":image")
        $(":reset")
        $(":button")
        $(":file")
           
//        匹配所有input,select标签中可用的元素
        $(":enabled")
//        匹配所有input,select标签中不可用的元素
        $(":disabled")
        $(":checkbox")
        $(":selected")      
</script> </body> </html>
           

  

转载于:https://www.cnblogs.com/kongzhagen/p/6193947.html

继续阅读