jQuery Mobile: Use same header footer for all pages

前端 未结 3 2229
陌清茗
陌清茗 2021-02-20 16:13

I\'m trying to implement some code that will create the headers and footers on all of my web pages instead of hard coding them. I tried this:

I had this in my \"main pag

3条回答
  •  情深已故
    2021-02-20 16:39

    Using .load() may help, then just put the code you want to include in the file you are linking to.

    $('.headerChild').load('pathto/headerProto.html')
    

    An alternative way if you do not want to keep the data in a separate file: I have not done this but from some quick research you can also link to an element within the file.

    $('.headerChild').load('pathto/mainPage.html #headerProto')
    

提交回复
热议问题