Answers for "include html inside html"

1

include html file in html file

// js
<script>
$(function () {
  var includes = $('[data-include]')
  $.each(includes, function () {
    var file = $(this).data('include')
    $(this).load(file)
  })
})
</script>
// html
<div data-include="header.html"></div>
<div data-include="footer.html"></div>
Posted by: Guest on December-27-2021
0

include html

<!-- a.html: -->

<html> 
  <head> 
    <script src="jquery.js"></script> 
    <script> 
    $(function(){
      $("#includedContent").load("b.html"); 
    });
    </script> 
  </head> 

  <body> 
     <div id="includedContent"></div>
  </body> 
</html>

<!-- b.html: -->

<p>This is my include file</p>
Posted by: Guest on September-25-2021

Browse Popular Code Answers by Language