replilian replilian - 1 year ago 61
HTML Question

Can I import only a piece of html from an external file?

I need to create an html file that contains only content within a form tag of another html file, and nothing else. Is there any way to do this?

Answer Source

You can dynamically load html snippets after your main page loads using javascript. Something like this:


        <script src=""></script>
        <script src="script.js"></script>
        <div id="container"></div>


    <input value="testing" />


var formUrl = 'form.html';

$(window).on('load', function(){
  $.get(formUrl, function(res){

Here is a working plunk

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download