新手上路 jquery 选择器篇(三) 代码笔记

<head>
    <meta charset="UTF-8">
    <title></title>
    <script type="text/javascript" src="js/jquery-3.2.1.js"></script>

</head>
<body>
    <!--
        选择器                   名称                                 举例
        表单选择器           :input        查找所有的input元素:$(":input")
        注意:会匹配所有的input、textarea、select和button元素。
        文本框选择器        :text          查找所有文本框:$(":text")
        密码框选择器        :password 查找所有密码框:$(":password")
        单选按钮选择器     :radio       查找所有单选按钮:$(":radio")
        复选框选择器        :checkbox 查找所有复选框:$(":checkbox")
        提交按钮选择器     :submit     查找所有提交按钮:$(":submit")
        图像域选择器        :image      查找所有图像域:$(":image")
        重置按钮选择器    :reset         查找所有重置按钮:$(":reset")
        按钮选择器           :button      查找所有按钮:$(":button")
        文件域选择器        :file           查找所有文件域:$(":file")


    -->
    <form id="myform" method="post" name="myform">
        姓名:<input type="text" name="uname" id="uname" value="" />
        <br />
        密码:<input type="password" name="upwd" id="upwd" value="147258" />
        <br />
        职业:
            <input type="radio" name="ulive" id="" value="0" checked="checked"/>修仙
            <br />              
            <input type="radio" name="ulive" id="" value="1"/>修魔
            <br />
            爱好: 
            <input type="checkbox" name="fav" id="" value="足球" />足球
            <br />
            <input type="checkbox" name="fav" id="" value="running" />running
            <br />
            <input type="checkbox" name="fav" id="" value="蓝球" />蓝球
            <br />
            <input type="checkbox" name="fav" id="" value="各种撸" />各种撸
            <br />
            <input type="checkbox" name="fav" id="" value="book" />book
            <br />
        君归处:
                <select name="myselect" id="myselect">
                    <option value="0">浙江</option>
                    <option value="1">天津</option>
                    <option value="2">天南</option>
                </select><br />

        <input type="hidden" value="15" name="hid" disabled="disabled"/>

        <button>提交</button>

    </form>
</body>

<script type="text/javascript">
    //表单选择器 :input  --->会匹配所有的input、textarea、
    //select和button元素。
    var inputs = $(':input');
    inputs.each(function(){
        console.log(this);
    });

    console.log(">=--------------密码框选择器------------->")
    var pass = $(':password');
    pass.each(function(){
        console.log(this);
    });

    console.log(">=--------------文本框选择器------------->");
    //文本框选择器 :text
    var texts = $(':text');
    texts.each(function(){
        console.log(this);
    });

    console.log(">=--------------单选按钮选择器  ------------->");
    var radio1 = $(':radio');
    radio1.each(function(){

        console.log(this);
    });

    console.log(">=--------------复选框选择器 (其他的类似,不在追叙)------------->");
    var checkbox1 = $(':checkbox');
    checkbox1.each(function(){

        console.log(this);
    });



</script>
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值