我正在尝试获取以前的 html 并再次将其加载到这样的 div 中:
$("#start_val").change(function(){
var script = $("#search_result_cont").html();
$("#search_result_cont").empty();
$("#search_result_cont").html(script);
});
首先,我尝试将 search_result_cont 内部 html 放入脚本变量中,然后使用 empty() 函数将 search_result_cont div 设为空,然后尝试再次将相同的 html 插入到 search_result_cont 中。但是当我这样做时,html开始以整页而不是在search_result_cont div中显示
这就是 searchresult_cont 所拥有的
<div class="search_result_cont" id="search_result_cont">
<script language="javascript">
var offers = <?php echo $jsonencoded;?>;
var node = offers.offer;
var resultpage = parseInt(node.length) / 10;
var result_start = document.getElementById('start_val').value;
var result_limit = parseInt(result_start) + 9;
for(var i=result_start;i<=result_limit;i++)
{
document.write("<div class='result_box'><div class='result_left_area'><div class='result_title'>"+node[i].name+"<div class='result_stars'></div></div><div class='result_pic'><div class='show_image'></div><img src='"+node[i].image_url+"' style='height:100%; width:100%;' /></div><div class='result_icons_cont'><div class='share_icon' title='Share'></div><div class='information_icon' title='information'></div><div class='review_icon' title='Reviews'></div><div class='miles_icon' title='View Location' ></div></div><!--result_icons_cont ends--><div class='result_links_cont'><div class='result_link'>Website 1<span>"+node[i].currency+" "+node[i].price_no_vat+"</span></div></div><div class='view_all_prices'>View all prices from 12 websites <span style='font-size:20px; color:#32ccfe;'>»</span></div></div><div class='result_best_site'><div class='best_site'><img src='images/hotels/267_mx_bg.png' /></div><div class='round_corner_btn' onclick='window.open="+node[i].offer_url+"'></div></div><!--result_best_site ends --><div class='information_cont' id='share_info'>Shares: 6</div><!--information_cont share_info ends--><div class='information_cont' id='information_info'>Hotel Address:- "+node[i].address+","+node[i].city+"<br />Website:- <a href='"+node[i].offer_url+"'>Link</a><br />About:- "+node[i].description+"</div><!--information_cont information_info ends--><div class='information_cont' id='review_info'><input type='hidden' id='review_value' value='' /></div><!--information_cont review_info ends--><input type='hidden' id='lonlat' value='20.63536,476.98787' /><div class='information_cont' id='miles_info'></div><!--information_cont miles_info ends--><input type='hidden' id='picture_count' value='' /><input type='hidden' id='picture_url' value='' /><div class='information_cont' id='images_info'></div><!--information_cont images_info ends--><div class='information_close' title='close'></div></div><!--result_box ends here-->");
}
document.write("<div class='pagination_btn_cont'>");
for(var page = 1;page<=resultpage;page++)
{
document.write("<div class='pagination_btn'>"+page+"</div>");
}
document.write("</div><!--pagination_btn_cont ends-->");
</script>
</div><!--search_result_cont ends here-->