jQuery-基本

 

<!DOCTYPE html>
<html>
<head>
<script src="jquery/jquery-1.11.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("#but1").click(function(){
    alert($("#x").length);
  });//id 选择器
  $("#but2").click(function(){
    alert($("div").length);
  });//标签名 选择器
  $("#but3").click(function(){
    alert($(".y").length);
  });//class 选择器
  $("#but4").click(function(){
    alert($("#z *").length);
  });//id"z"下的全部 选择器
  $("#but5").click(function(){
  alert($("#z,.y").length);
  });//id,class 选择器
  //基本

}); </script> </head> <body> <input id="but1" type="button" value="id"> <input id="but2" type="button" value="标签名"> <input id="but3" type="button" value="class"> <input id="but4" type="button" value="*"> <input id="but5" type="button" value="多项"> <div id="z"> <p>#z子级p1</p> <p>#z子级p2</p> <div id="x">div #x</div> <span>span</span> <div>div</div> <div class="y">div .y</div> <span>span</span> <div>div</div> </div> </body> </html>

 

posted on 2017-02-09 21:56  加号与剑豪  阅读(107)  评论(0)    收藏  举报

导航