使用Jquery顺序加载DIV [英] Sequentially Load DIV using Jquery

查看:98
本文介绍了使用Jquery顺序加载DIV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用预加载器使用Jquery加载一系列DIVS.

Is it possible to load a series of DIVS using Jquery using a preloader.

例如,我有一个页面,其中4个div嵌套在1个主要div内.

For instance, I have a page with 4 divs nested within 1 main div.

我想先加载content1,然后再加载content2,依此类推.

I'd like to load content1, then content2, and so on.

此外,序列中一次只能加载1个div.

Plus, only 1 div will load at a time in the sequence.

使用jquery或其他方法是否可能?

Is this possible with jquery, or anything else?

推荐答案

是的,请使用 jQuery.load() ; ,从Content1开始,并从.load();在 complete 回调上触发Content2的加载.

Yes, use jQuery.load();, begin with Content1 and trigger the loading of Content2 on the complete callback from .load();.

示例:

$("#Div1").load("ajax/Content1.php", function() {
  $("#Div2").load("ajax/Content2.php", function() {
    //(And so on...)
  });
});

编辑:我只是假设加载"是指通过ajax加载动态内容(如带有您的帖子所标记的PHP).

I just assumed by "load" you meant loading dynamic (like PHP which your post is tagged with) content through ajax.

这篇关于使用Jquery顺序加载DIV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆