[英]jQuery load a whole html table with script tag
I would like to load a whole table from table.html that contains javascript, but unfortunately it does not load into the index.html file.我想从包含 javascript 的 table.html 加载整个表格,但不幸的是它没有加载到 index.html 文件中。
index.html索引.html
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="js.js"></script>
<script>$( "#load" ).load( "load.html" );</script>
</head>
<body>
<div id="load"></div>
</body>
</html>
js.js js.js
function make(number) {
document.write('<td align="center"valign="bottom" nowrap>'+number+'</td>');
}
load.html加载.html
<script src="js.js"></script>
<table border="1">
<div>
<tr>
<script>
make(1342);
</script>
</tr>
</div>
<div>
<tr>
<script>
make(133);
</script>
</tr>
</div>
</table>
index.html -> You can insert an iframe
which can load your table.html file index.html -> 您可以插入可以加载 table.html 文件的iframe
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$(document).ready(function () {
$("#load").attr("src", "table.html");
});
</script>
</head>
<body>
<iframe id="load" src="" ></iframe>
</body>
</html>
table.html
<html>
<head>
<script src="js.js"></script>
</head>
<body>
<table border="1">
<div>
<tr>
<script>
make(1342);
</script>
</tr>
</div>
<div>
<tr>
<script>
make(133);
</script>
</tr>
</div>
</table>
</body>
</html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.