jQuery02

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title></title>
        <style type="text/css">
            .e{
                background: green;
            }
            .o{
                background: yellow;
            }
            </style>
        <!--引用js库-->
  <script src="js/jquery-3.3.1.js" type="text/javascript" charset="utf-8"></script>
  <script type="text/javascript">
      $(function(){
        //数组
//         var names=["aa","bb","cc"];
//         //遍历数组
//         $.each(names,function(i,v){
//             console.info(v);
//         })
//            var stu={"name":"张三","age":12};
//            $.each(stu,function(k,v){
//                console.info(v);
//            })
                  // console.info(stu.name,stu.age);})
                  
                  
                  //对象数组
                  // var stus=[{"name":"大炮","age":18},{"name":"大炮1","age":17}];
                  //遍历对象数组
                  // $.each(stus,function(i,stu){
                      // console.info(stu.name,stu.age);
//                       $.each(stu,function(k,v){
//                           console.info(v);
//                       })
//                   })
                                 /*$.trim 去除左右俩边的空格*/
//                               var str="   不要对我尖叫    ";
//                               console.info(str.length);
//                               console.info($.trim(str).length);
                        
                        /*$.type 判断数类型*/
//                           console.info($.type(1,3));
//                           console.info($.type("aa"));
//                           var names=["aa","bb","cc"];
//                           console.info($.type(names));
//                           var stu={"name":"张三","age":12};
//                             console.info($.type(stu));    
                         // $.isArray()判断是否是数组
//                          var stus=[{"name":"大炮","age":18},{"name":"大炮1","age":17}];
//                          console.info($.isArray(stus));
                           // console.info($.isFunction(myf));
                           //解析 将字符串-->对象
//                            var stu={"name":"张三","age":12};
//                            var p=$.parseJSON(stu);
//                            console($.type(p));
//                            console.info(p.name,p.age);
                                     
                                     
                                     
                                     
                                     //解析 将字符串-->对象数组
//                                var stus='[{"name":"大炮","age":18},{"name":"大炮1","age":17}]';
//                                var p=$.parseJSON(stus);
//                                $.each(p,function(i,stu){
//                                    console.info(stu.name,stu.age);
//                                })
                                           // attr 获取到属性值
//                                var h=$("#baidu").attr("href");
//                            console.info(h);
                             // 设置属性
//                               $("#baidu").attr("href","http:www.baidu.com");
//                                // 移除属性
//                               $("#baidu").removeAttr("href");
                                        // addClass 增加class 属性
//                               $("#baidu").addClass("du");//叠加
//                               $("#baidu").attr("class","du");//覆盖
                                   // 移除class属性值
                               // $("#baidu").removeClass();
                               
//                                        $("#baidu").attr("name","aa");
//                                        $("#bandu").prop("name","aa");
                                 /* 案列:四*/
//                                 $("#ok").click(function(){
//                                     $(".abc").prop("checked",true);
//                                 })
//                                 $("#nook").click(function(){
//                                     $(".abc").prop("checked",false);

                            /*案列三:隔行取色*/
//                             $("table tr:even").addClass("e");
//                             $("table tr:odd").addClass("o");
                           //将子项全部显示处理
//                            var s=$("p").html();
//                            console.info(s);
//                            //只获取文字信息
//                            var b=$("p").text();
//                            console.info(b);
                          /*css*/
                           // $("p").css({"background":"yellow","color":"pink"});
                           $("p").css("background","rgb(255,222,10)");
                          var a=$("p").css("background");
                          console.info(a);
                           

    })                          
//                            function myf(){
//                                alert("sss");
//                            }
  </script>
    </head>
    <body>
             <h2>案列二:属性</h2>
             <a id="baidu" class="bai">百度一下</a>
             <h2>案列三:隔行取色</h2>
             <table border="1px" width="500px">
                 <tr>
                     <td>&nbsp;</td>
                     <td>&nbsp;</td>
                 </tr>
                 <tr>
                     <td>&nbsp;</td>
                     <td>&nbsp;</td>
                 </tr>
                 <tr>
                     <td>&nbsp;</td>
                     <td>&nbsp;</td>
                 </tr>
                 <tr>
                     <td>&nbsp;</td>
                     <td>&nbsp;</td>
                 </tr>
                 <tr>
                     <td>&nbsp;</td>
                     <td>&nbsp;</td>
                 </tr>
                 <tr>
                     <td>&nbsp;</td>
                     <td>&nbsp;</td>
                 </tr>
                 </table>
             <h2>案列四:购物车全选 取消全选</h2>
             爱好:<input type="checkbox" class="abc" value="睡觉" />睡觉
             <input type="checkbox" class="abc" value="干饭" />干饭
             <input type="checkbox" class="abc" value="打游戏">打游戏<br/>
             <input type="button" value="全选" id="ok">
             <input type="button" value="取消全选" id="nook">
             <p>尖叫于口,<span>大炮</span></p>
    </body>
</html>

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值