I want to keep the code short and clean. So I'm importing tons of HTML files.
I have this in head:
<script>
var loadHtml(file) {
$("#LoadHTML").load("html/file.html");
});
</script>
And this in body:
<div id="LoadHTML"></div>
The problem is I have to duplicate the script for each <div> I have.
Is there a way I can make a placeholder in the script and do what I have visualized?
<!-- Head -->
<script>
$(function(){
$("#LoadHTML").load("html/{data}.html");
});
</script>
<!-- Body -->
<div id="LoadHTML" data="file"></div>
How do I do it so I only have to use the script once?