jQuery核心方法
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($("div").length); });//获取对象 标签选择器 $("#but2").click(function(){ alert($("p").length); });//获取对象 标签选择器 $("#but3").click(function(){ alert($("#x").length); });//获取对象 id选择器 $("#but4").click(function(){ alert($(".z").length); });//获取对象 class选择器 $("#but5").click(function(){ alert($("[type=‘y‘]").length); });//获取对象 属性选择器 }); </script> </head> <body> <input id="but1" type="button" value="几个div"> <input id="but2" type="button" value="几个p"> <input id="but3" type="button" value="几个id"> <input id="but4" type="button" value="几个class"> <input id="but5" type="button" value="几个type"> <div><p>div,p:1</p></div> <div><p>div,p:2</p></div> <div id="x">div,id:3</div> <div class="z">div,class:4</div> <div type="y">div,type:5</div> </body> </html>
原文:http://www.cnblogs.com/yjh1604600160/p/x1.html