我試圖克隆(或移動)信息從一個頁面到另一個使用jQuery和Ajax。此代碼目前沒有爲我做任何事情,是我必須與之合作:jQuery克隆或從另一個頁面移動Ajax信息
本質上它是檢查頁面ID爲Deal_1
。如果找到我想要移動(或克隆)這三個div 是在頁面被檢查與類deal-product-name
deal-saving-stock-details
& deal-end
,到我目前的頁面。
$.ajax({
url: "http://tsqja.deznp.servertrust.com/dealoftheday.asp",
context: document.body,
dataType: 'html',
success: function(data){
if ($(data).find('#Deal_1').length >= 1) {
$('#dealofdaytop').after($('.deal-product-name'));
$('#dealdayprice').after($('.deal-saving-stock-details'));
$('#dealdayprice').after($('.deal-end'));
}
});
這是當前頁面上我想的div移動到:
<div class="deal" id="dealday">
<div id="dealofdaytop" align="center"><img style="opacity:0.8;filter:alpha(opacity=80)" src="http://www.mysite.com/v/newsite/dealofday/dealofdaytop.png"> </div>
<div id="dealdayprice" style="height: 60px;"></div>
<div id="dealdaybg"></div>
</div>
應該不使用.after()的.append()intead嗎? –