Home >Web Front-end >JS Tutorial >Examples of each method and common selectors in jquery_jquery

Examples of each method and common selectors in jquery_jquery

WBOY
WBOYOriginal
2016-05-16 16:42:181333browse
 <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>

Commonly used selectors:

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

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