Created
April 28, 2022 13:38
-
-
Save samuelastech/c5706e68f9817d4ed3f50c4fbfff3c4e to your computer and use it in GitHub Desktop.
Using jQuery 'load' function we can break our HTML files into smaller parts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="./js/jquery-3.6.0.js"></script> | |
<script> | |
$(function () { | |
const includes = $('[data-include]') | |
$.each(includes, function(){ | |
let file = 'includes/' + $(this).data('include') + '.html' | |
$(this).load(file) | |
}) | |
}) | |
</script> | |
<div data-include="main"></div> | |
<div data-include="footer"></div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment