我正在另一个html页面中加载一个html页面,比如说,home.html
在index.html
内部调用,但现在我想更改的一些内容>home.html
借助 index.html
内的 java 脚本或 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>
最佳答案
.load()
调用是异步的。因此您需要等待它完成后再进行更改。
类似于:
$('body').load('home.html', function() {
$('#session_error').html("This is session out errror");
});
关于javascript - 如何更改加载到其他 html 的 body 标记内的 html 内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47323839/