[英]How to load a JavaScript file in the Blazor client index.html
[英]How to load another html inside index.html on click Javascript
我有一個 index.html 文件,它是一個按鈕。 我有一個 modal.html 文件,它內置了一個自定義模態。 我想onclick
事件渲染 modal.html 里面的 index.html 並正常關閉它。 任何人都可以用純 Javascript function 幫助我嗎?
index.html 下面的例子
<div id="modal-container">
// here I want to load content from modal.html
</div>
modal.html
<div>
//here is modal content
</div>
有多種方法可以將.html
文件渲染到另一個文件中。
iframe
標簽內聯框架用於在當前 HTML 文檔中嵌入另一個文檔。
<iframe src="modal.html"></iframe>
具體使用 jQuery 的.get()
方法:
$.get("modal.html", function(data) {
$("#modal-container").html(data);
});
<?php include 'modal.html'?>
在您的情況下,您可以使用 jQuery 的$.get()
方法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.