Home > Web Front-end > JS Tutorial > body text

Examples of each method and common selectors in jquery_jquery

WBOY
Release: 2016-05-16 16:42:18
Original
1274 people have browsed it
 <head> 
<title></title> 

<script src="jquery-1.4.2.js" type="text/javascript"></script> 
<script type="text/javascript"> 

$(function() { 
//alert($("div").text()); 
//对数组元素使用匿名函数进行逐个处理。 
$("div").each(function(key, value) { 
//alert(key+value); 
// alert($(value).text()); 
alert(this.innerHTML); 
}); 
//this表示当前遍历的dom元素 
$("div").each(function() { 
alert($(this).text()); 
}); 
}); 
</script> 
</head> 
<body> 
<div id="testDom">11111</div> 
<div>2222</div> 
<div>33333</div> 
</body>
Copy after login

Commonly used selectors:

1. Class: $(".error").
2.id:$("#daLong").
3. Tag: $("div").
4. Attribute: $("div[name=apple]").
5. Form: $("input:checked").

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!