代码如下,使用each遍历即可
$(".div a").each(function(index, element) {
$(this).attr('href',$(this).attr('href')+"&type=" + index);
});
本文介绍了一种使用jQuery的each方法遍历指定元素,并动态修改其href属性的方法,通过添加参数'type'和对应的索引值,实现对每个元素的个性化链接设置。
代码如下,使用each遍历即可
$(".div a").each(function(index, element) {
$(this).attr('href',$(this).attr('href')+"&type=" + index);
});
949
1001

被折叠的 条评论
为什么被折叠?