Home  >  Article  >  Web Front-end  >  Examples of each method and common selectors in jquery

Examples of each method and common selectors in jquery

巴扎黑
巴扎黑Original
2017-07-09 11:20:21827browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn