0
jquery noob,所以不要太費勁地試試plz。 在產品描述中獲得帶有表格的產品網格。表td具有相同的類,當我嘗試從其中的每一箇中拉出內容並插入到不同的位置時,我仍然會獲得相同的內容,這些內容在每個產品中都有所不同。jquery:從同一類別的不同div中拉出不同的內容
這裏是HTML
<div class="product">
<div class="product777">
<table>
<tr><td class="varimage1">content 1</td><td class="varimage2">COntent2</td></tr>
</table>
<div class="galitem1"></div>
<div class="galitem2"></div>
</div></div>
這裏是一段js代碼
$(".product").each(function(){
// tried this
var colorimgab = $(".varimage2").html();
//and tried this
var colorimgaa = $(this).closest(".product777").find(".varimage1").html();
$(".galitem1").html(colorimgaa);
$(".galitem2").html(colorimgab);
});
瓦在'.product'和'.product777'?編輯了 – 2014-11-04 08:32:00
。搞砸了簡化代碼 – whaaaaaaz 2014-11-04 08:38:50