Partial render in HTML/JavaScript

前端 未结 5 2023
再見小時候
再見小時候 2020-12-24 07:17

I have some HTML files, and each one of them I want to partially render in another HTML file, for example header.html and footer.html in order to o

5条回答
  •  Happy的楠姐
    2020-12-24 08:06

    If you're just using plain HTML and Javascript, you could include jQuery and use an AJAX request to load the contend of another HTML page in your main page.

    Have a look at the jQuery 'load()' function here:

    http://api.jquery.com/load/

    Assuming your have the following html:

    
    

    your usage would look something like this:

    $('#header').load('header.html');
    $('#footer').load('footer.html');
    

提交回复
热议问题