深入理解jquery中的each用法

2020-05-27 18:02:36易采站长站整理

<script >
// 在each()循环里 element == $(this)
$('button').click(function(){
$('div').each(function(index,element){
//element == this;
$(element).css("background","yellow");

if( $(this).is("#stop")){
$('span').text("index :" + index);
return false;
}
})
})
</script>
</html>