0
我有以下4個空白圖像(圖像從背景網址來)jQuery的分配圖像連續元素
<div style="float: left; display: block; width: 50%;">
<p>Choose 4 Club Items</p>
<br>
<a href="#product_grid"><span class="empty-plus-container"><img src="criteria1"></span></a>
<a href="#product_grid"><span class="empty-plus-container"><img src="criteria1"></span></a>
<a href="#product_grid"><span class="empty-plus-container"><img src="criteria1"></span></a>
<a href="#product_grid"><span class="empty-plus-container"><img src="criteria1"></span></a>
</div>
下面我DIV有「添加」按鈕,產品網格。
現在當我添加第一個產品時,我想要在第一個元素中填充產品圖像。
同樣,當我添加多個產品時,它們的圖像應填充到下一個元素中。
我試着用下面的函數,但它是一次填充所有的元素。
var items = document.getElementsByName('criteria1');
for(var x = 0; x < items.length; x++) {
items[x].setAttribute("src","second.jpg");
}
任何想法如何由一個而不是一次全部做到這一點的。