简体   繁体   English

用jquery加载元素时是否可能会发出警报?

[英]Is it possible alert when an element is loaded with jquery?

Here's the example I'm working with, I'm trying to get an alert when the element is loaded in to the page with jquery .load, but can't seem to get it right, any suggestions? 这是我正在使用的示例,当尝试使用jquery .load将元素加载到页面中时,我试图获取警报,但似乎无法正确执行任何建议? is this possible? 这可能吗?

http://jsfiddle.net/ZhsBR/2/ http://jsfiddle.net/ZhsBR/2/

html: 的HTML:

<div id="nav1">click to load content</div>
<div id="target"></div>

js: js:

$("#nav1").click(function() {
    $('#target').load('http://fiddle.jshell.net/user/login/ #content > *');
});

$("#pageContainer").ready(function() {
    alert("dynamic content has been loaded");
});

It's called a callback, you must supply one in your load() function. 这称为回调,您必须在load()函数中提供一个。

$('#target').load('http://fiddle.jshell.net/user/login/ #content > *', function(){
    //the request is complete
    alert("Dynamic Content Has Been loaded");
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM