[英]Change div content after loading it with ajax load method
Try to call the function inside the ajax call function.尝试调用ajax调用函数内部的函数。
$('.container').load('new.html',function(){
$('#rr').html('modified')
});
next time please do not put image for code.下次请不要为代码放图片。
why your code $('#rr').html('modfied');
为什么你的代码$('#rr').html('modfied');
is not working because you are calling the change before jquery ajax.load() method is able to load the content from your new.html
and as result your id #rr
is not found.不工作,因为您在 jquery ajax.load() 方法能够从您的new.html
加载内容之前调用更改,结果您的 id #rr
未找到。 So, instead of calling the modify code after the load statement call the modifying statement in your load()'s complete() as:因此,不要在 load 语句之后调用修改代码,而是调用 load() 的 complete() 中的修改语句,如下所示:
$('#btn').on('click', function () {
$('.container').load('new.html', function () {
$('#rr').html('modfied');
});
});
and please go through the jquery documentation for more info on how to use the functions Jquery Documentation for Load() funciton .并请阅读 jquery 文档以获取有关如何使用Load()函数的Jquery 文档功能的更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.