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

android - net_scheduler holding wakelock -

sql - MySQL : Getting Entries from a many-to-many table -

java - Retrieving data from database using jsp (Hibernate + Spring + Maven) -