我正在其他地方加载一个html页面,假设home.html
在index.html
内调用,但现在我想在java脚本的帮助下更改home.html
的某些内容或index.html
内的jquery
以下是我到目前为止所尝试的内容
的index.html
<html>
<body> </body>
</html>
<script>
$('body').load('home.html');
// below div **session_error** is from home.html page,I wanted to change its text on this page
$('#session_error').html("This is session out errror");
</script>
答案 0 :(得分:2)
.load()
调用是异步的。因此,您需要在进行更改之前等待它完成。
类似的东西:
$('body').load('home.html', function() {
$('#session_error').html("This is session out errror");
});