Jquery 将外部txt文件加载到DIV中

Jquery 将外部txt文件加载到DIV中,jquery,Jquery,关于上面的提琴,在滑入视图之前,如何使用块1中的不同链接加载块2中的外部文件(txt、HTML)?我知道JQuery.load()将是该过程的一部分 $(".block2").load("helloworld.txt"); 这应该可以工作-提供动画作为对.load()函数的完整回调 $(function() { $(".link1").click(function() { $.load("url/to/load/from", function() {

关于上面的提琴,在滑入视图之前,如何使用块1中的不同链接加载块2中的外部文件(txt、HTML)?我知道JQuery.load()将是该过程的一部分

$(".block2").load("helloworld.txt");

这应该可以工作-提供动画作为对.load()函数的完整回调

$(function() {
    $(".link1").click(function() {
        $.load("url/to/load/from", function() {
            //Insert contents of file wherever
            $(".block1").stop(true, true).animate({ left: -400 }, 200);
            $(".block2").stop(true, true).animate({ left: 25 }, 200);
        });
    });

    $(".link2").click(function() {
        $.load("url/to/load/from", function() {
            //Insert contents of file wherever
            $(".block2").stop(true, true).animate({ left: 450 }, 200);
            $(".block1").stop(true, true).animate({ left: 25 }, 200);
        });
    });
});

这应该可以工作-提供动画作为对.load()函数的完整回调

$(function() {
    $(".link1").click(function() {
        $.load("url/to/load/from", function() {
            //Insert contents of file wherever
            $(".block1").stop(true, true).animate({ left: -400 }, 200);
            $(".block2").stop(true, true).animate({ left: 25 }, 200);
        });
    });

    $(".link2").click(function() {
        $.load("url/to/load/from", function() {
            //Insert contents of file wherever
            $(".block2").stop(true, true).animate({ left: 450 }, 200);
            $(".block1").stop(true, true).animate({ left: 25 }, 200);
        });
    });
});

我用那行代码更新了小提琴,所以它做的第一件事就是加载。然而,如何在加载之前阻止它滑动?我用那行代码更新了小提琴,所以它做的第一件事就是加载。但是,如何在加载之前阻止它滑动?我必须在.load前面添加(“.block2”),但是第一个文件的动画效果很好,当我单击第二个链接加载第二个文件时,加载发生了,但它没有动画效果。我必须在.load前面添加(“.block2”),但是第一个文件的动画效果很好,当我单击第二个链接以加载第二个文件时,会加载,但不会设置动画。