2

我有一个动态列表加载到使用jquery mobile +(jquery和javascript)构建的HTML 5 web应用程序中。动态内容的jquery.ready事件

我想通过在页面上放置一个<div>来显示简单的“加载...”图像,同时动态填充列表。一旦清单完成,我需要一个事件来消除“加载...”图像。是否有可能将.ready或.load事件附加到动态列表的元素,以便在列表加载时触发事件触发?

感谢您的任何建议,在.ready主题上搜索现有答案只会提供关于document.ready使用该事件的结果。

回答

2

使用回调函数。

$(function() { 
    $('#content').html('<div>loading...</div>'); 
    $('#content').load('http://mynewcontent.com/', function(data) { 
     // optional: do more stuff here.. not needed since the content will already be replaced. 
    }); 
}); 
+0

感谢这很好地解决了我的问题。 – ThunderHorse 2011-12-19 02:15:55