2_4表单选择器

表单选择器

关于表单项的选择器

:text :password :radio :checkbox :hidden :file :submit

:input 匹配所有 input, textarea, select 和 button 元素

关于表单项状态的选择器

:selected :checked :enabled :disabled :hidden :visible

注意$("input")和$(":input")的区别

$("input"):标签选择器,只匹配input标签,$(":input"): 匹配所有 input, textarea, select 和 button 元素

<!DOCTYPE html>
<html>
    <head>
         <meta charset="utf-8">
         <title>表单选择器</title>
         <style type="text/css">
             .myClass {
                  background-color: aqua;
             }
         </style>
         <script src="js/jquery.js"   type="text/javascript"></script>
         <script type="text/javascript">
             $(function() {
                  //:text   :password    :radio  :checkbox  :hidden    :file  :submit 
                  //var arr =$("input"); // 标签名选择器
                  
                  //var arr = $("input[type=hidden]"); 
                  //var arr = $("input:hidden");              
                  //:input  匹配所有 input, textarea, select 和 button 元素 
                  //var arr =   $("input,select,textarea,button");   
                  //var arr = $(":input"); 
                  //:selected    :checked  :enabled  :disabled   
                  //var arr = $(":disabled"); 
                  //var arr = $(":enabled"); 
                  //var arr = $(":input:not(:disabled)"); 
                  //var arr = $(":checked"); 
                  //var arr = $(":selected"); 
                  //:hidden :visible       
                  //var arr = $("input:hidden") 
                 /* var   arr = $(":input:visible")
                  for(var i = 0; i < arr.length; i++) {
                      console.info(arr[i]);
                  }*/
             });
         </script>
    </head>
    <body>
         <h3>注册用户</h3>
         <form action=""   method="get">
             <table border="1"   width="40%">
                  <tr>
                      <td>用户名</td>
                      <td>
                      	  <input type="text"   name="username"   value="请输入姓名" />
                          <input type="hidden"   name="username"   id="username"   value="请输入姓名"    />
                      </td>
                  </tr>
                  <tr>
                      <td>密 码</td>
                      <td><input type="password"   name="pwd"   id="pwd" disabled="disabled"   /></td>
                  </tr>
                  <tr>
                      <td>确认密码</td>
                      <td><input type="color"   name="repwd"   id="repwd"   /></td>
                  </tr>
                  <tr>
                      <td>性别</td>
                      <td>
                           <input type="radio"   name="sex"   value="男" />男
                           <input type="radio"   name="sex"   checked="checked"   value="女" />女
                      </td>
                  </tr>
                  <tr>
                      <td>年龄</td>
                      <td><input type="text"   min="6"   max="30"   name="age"   id="age"   value="18"   /></td>
                  </tr>
                  <tr>
                      <td>电子邮箱</td>
                      <td><input type="text"   name="email"   id="email"   /></td>
                  </tr>
                  <tr>
                      <td>籍贯</td>
                      <td>
                          <select name="pro">
                          	<option value="1">京</option>
                          	<option value="2" selected="selected">津</option>
                          	<option value="3">冀</option>
                          </select>
                      </td>
                  </tr>
                  <tr>
                      <td>自我介绍</td>
                      <td>
                         <textarea name="intro"></textarea>
                      </td>
                  </tr>
                  <tr>
                      <td colspan="2">
                      	<input type="submit" />
                      	<input type="reset" />
                      	
                      </td>
                      
                  </tr>
             </table>
         </form>
    </body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值