jquery - Is it okay to add DOM Elements with Javascript to create the webpage? -


in php, can include other files (such header or footer file - i'll call them partials) serve specific page - allows minimal amount of inconsistencies within pages. however, html not have feature. i've implemented solution whereby javascript @ end of page adds static partials after document has announced ready:

$(function() {   html = "<div id=\"navbar\"><h1>cool webpage!</h1></div>";   $("#header").append(html); }); 

the #header <div> uppermost portion of <header> - it's used target node #navbar injected into.

as far can see, feasible workaround mitigate inconsistencies across pages, feel i'm being bit naive.

is method okay implement, or there better way? ajax in html add, , still add on fly? there issues should watch out if implementing method?


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -