jQuery中的:input选择器

来源:互联网 发布:淘宝导航条字体颜色 编辑:程序博客网 时间:2024/04/29 11:14

jQuery中的:input选择器

jQuery中的:input选择器包括input, textarea, select 和 button这些标签。

<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>Document</title>    <style type="text/css">        ul {            margin-left: 20px;            color: blue;          }          li {            cursor: default;          }          span {            color: red;          }    </style></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">  <select>    <option>Option</option>  </select>  <textarea></textarea>  <button>Button</button></form><div id="messages"></div>    <script src="jquery-2.1.4.js"></script>    <script>        $("#messages").text($(":input").length+":"+$("form>*").length)    </script></body></html>

所以结果为form中的所有元素都会被 :input 选择器选中。

1 0
原创粉丝点击