How To Make Reuseable HTML Navigation Menus?

前端 未结 10 685
面向向阳花
面向向阳花 2021-01-02 04:41

I\'m sure this topic comes up all the time,
But I can\'t seem to fine a concise answer.

I\'ve got a vertical menu bar that I want to reuse in webpages (>20)

10条回答
  •  清酒与你
    2021-01-02 05:27

    I was facing the same thing. Then, I created a new file for storing the html of the navigation bar.

    I created a file navbar.html which had all my navigation bar code. Then, in your main html file where you want navigation bar, just include this file by using jquery.

    $(document).ready(function() {
        $('#navigation').load('navbar.html');
    });
    

    Then at the place where you want navigation bar, just add this line:

    
    

提交回复
热议问题