Home > Article > Web Front-end > Examples of each method and common selectors in jquery
This article mainly introduces the use of each method and common selectors in jquery. Friends who need it can refer to
<head> <title></title> <script src="jquery-1.4.2.js" type="text/javascript"></script> <script type="text/javascript"> $(function() { //alert($("p").text()); //对数组元素使用匿名函数进行逐个处理。 $("p").each(function(key, value) { //alert(key+value); // alert($(value).text()); alert(this.innerHTML); }); //this表示当前遍历的dom元素 $("p").each(function() { alert($(this).text()); }); }); </script> </head> <body> <p id="testDom">11111</p> <p>2222</p> <p>33333</p> </body>
Commonly used selectors:
1. Class: $(".error").
2.id: $("#daLong").
3. Tag: $("p" ).
4.Attribute:$("p[name=apple]").
5.Form:$("input:checked").
The above is the detailed content of Examples of each method and common selectors in jquery. For more information, please follow other related articles on the PHP Chinese website!