我还在学习,所以我在绞尽脑汁。div的重复ID
$('.post-outer .post-footer .post-footer-line.post-footer-line-2 .post-labels a').each(function(index, el) {
$('.post-outer').attr('itemtype', $(this).attr('href'));
});
当你运行上面的JS时,它只需要在其他“DIV”中重复的第一个“href”。这是怎么回事:
<div class="post-outer" id="001" itemtype="url1">test1</div>
<div class="post-outer" id="002" itemtype="url1">test2</div>
<div class="post-outer" id="003" itemtype="url1">test3</div>
我想发生这样的:
<div class="post-outer" id="001" itemtype="url1">test1</div>
<div class="post-outer" id="002" itemtype="url2">test2</div>
<div class="post-outer" id="003" itemtype="url3">test3</div>
在这里的例子,它只是需要在最后一个div和其他 https://jsfiddle.net/mpb9wfmc/
你能添加你的html代码吗? – Diptox
https://jsfiddle.net/mpb9wfmc/ –
https://jsfiddle.net/mpb9wfmc/2/这里是 – Diptox