-1

我有 4 个 div。单击任何 div 时,我想加载第二个页面,但在该页面加载之前运行一些 jQuery。4 .Partition 在一页上,而#ContentBox1,2,3,4 在第二页上。我该如何进行这项工作?如果除了javascript之外还有其他方法可以做到这一点,我愿意接受所有建议。谢谢!

$('.Partition').click(
                function () {
                    var $this = $(this);
                    $('#ContentBox1').removeClass('active').css({ left: ($('#ContentBox1').width()) });
                    $('ContentBox' + $this.index()).addClass('active').css({ left: ($('#ContentBox1').width()) });
                }
        );
4

2 回答 2

1

You cannot modify a page that is not loaded into the browser. The script that modifies the other page has to be included in that same page. Period.

于 2013-11-03T18:36:50.163 回答
0

Load the div's from your AJAX with then set to either diplay:none or visibility:hidden, depending on your prefs. If this can't be done, add a div inside of the target div with the correct display/visibility. Use the AJAX callback to call whatever function required to modify the content, then set the display:block or visibility:visible.

Another option would be to place a div with display:none elsewhere on your page, load your content, modify the content after load. Then swap the content in the display:none div into your target div.

于 2013-11-03T18:38:24.480 回答