我有JQuery水平滑动div。在这些div中,我有一些对象,如果它们发生变化,需要重新加载网页。问题是,例如,如果我用#page3更改div中的对象,则重新加载会使用#page1将其抛回div,因为在网页加载时默认选择它。当用户在#page3 div上更改对象时如何实现,#page3 div在页面重新加载后仍保持选中状态。
JQUERY:
jQuery(function ($) {
$('a.panel').click(function () {
var $page = $($(this).attr('href')),
$other = $page.siblings('.active');
if (!$page.hasClass('active')) {
$other.each(function (index, self) {
var $this = $(this);
$this.removeClass('active').animate({
left: $this.width()
}, 500);
});
$page.addClass('active').show().css({
left: -($page.width())
}).animate({
left: 0
}, 500);
}
return false;
});
$('a.panel:nth(0)').click();
});
答案 0 :(得分:0)
将正在更改的面板的div或索引的id作为查询参数发送回服务器。在url的查询参数中重新加载页面时发回该值。然后从网址中提取页面加载的值,并使用javascript或jquery选择所述div。