码迷,mamicode.com
首页 > Web开发 > 详细

jQuery常用的基本选择器

时间:2017-02-20 19:52:02      阅读:200      评论:0      收藏:0      [点我收藏+]

标签:pre   val   text   button   script   基本   pos   inpu   访问   

常用基本选择器

用户名:
密 码:
性 别:

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>常用基本选择器</title>
    <script src="scripts/jquery-3.1.1.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function(){
            //获取构造jQuery对象,对应的元素是 id为form的所有元素

          //var  $form = $("#form");
            //访问对应的元素内部内容<form>内容</form>
           // alert($form.html());
           // var $c1 = $(".c1");
            //length:代表jQuery对象中有几个匹配的DOM对象
           // alert($c1.length);//选择器匹配几个就是有几个    2
            //元素选择器
            /*var $input = $("input");
            alert($input.length);*/ //alert弹出窗口
           /* 组合选择器
            var $all = $("input,button");
            alert($all.length);*/
            //全部的元素
            /*var $all = $("*");
            alert($all.length);*/

        });
    </script>
</head>
<body>
    <form id="form" action="#" method="post">
        用户名:<input id="name" class="c1" type="text" name="name"><br/>
        密 码:<input id="password" class="c1" type="password" name="name"><br/>
        性 别:<input name="sex" type="radio" value="male" checked>男
        <input name="sex" type="radio" value="female">女<br/>
        <input type="submit" value="提交">
        <input type="reset" value="重置"><br/>
        <button type="submit">提交</button>
        <button type="reset">重置</button>
    </form>
</body>
</html>

  

jQuery常用的基本选择器

标签:pre   val   text   button   script   基本   pos   inpu   访问   

原文地址:http://www.cnblogs.com/john568300/p/6420943.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!