![](/img/trans.png)
[英]How to include a html file inside another html file with Vanilla Javascript?
[英]How to include html file in another html file and then alert result via javascript jquery
我試圖將 html 文件包含在另一個 html 文件中,然后發出警報結果。
我在這里找到了解決方案。
源請我如何提醒b.html的內容而不是在 div 中調用它。
就像是
alert('b.html content here');
一個.html:
<html>
<head>
<script src="jquery.js"></script>
<script>
$(function(){
$("#includedContent").load("b.html");
alert('b.html content here');
});
</script>
</head>
<body>
<div id="includedContent"></div>
</body>
</html>
b.html:
<p>This is my include file</p>
jQuery 有一個方便的函數來獲取其他網頁, $.get()
:
$.get('b.html', function(data) {
alert(data);
});
function(data) {}
是在 http 請求成功時運行的回調, data
將包含響應正文。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.