使用Each()函数:
$(".CCC").each(function(i){
alert(this.id + " is the " + i + "th div with this class");
});
Run Code Online (Sandbox Code Playgroud)
编辑:
按照要求:
function LoopTroughDivs(selector){
$(selector).each(function(i){
alert(this.id + " is the " + i + "th div with this class");
});
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1792 次 |
| 最近记录: |