I tried the following code. But it doesn\'t work properly. Only one file add/ include repetitively. How can I solve this? **I want to create a custom tag \"\" which can INCL
is not a valid html
element.
You can use element with
rel
attribute set to "import"
to load resources into document
. At load
event of element you can get the content of resource using
link.import
$(function() {
$("body").append($("link[href='nav.html']")[0].import.body.innerHTML)
})
$("link[href='nav.html']").on("load", function() {
$("body").append(this.import.body.innerHTML)
})
Alternatively, you can use .load()
$("#element").load("nav.html");