Inject HTML and CSS using jquery but have the CSS in a separate file? -


i'm building going inject html users website via jquery hosted on server (their going include script other javascript already).

so have html injecting; how can not write inline style css injected html?

the idea have query server external javascript file @ beginning of jquery. i'm not sure how make both css , jquery available user's browser though.

any thoughts? i'm doing below, fyi.

$(document).ready(function() { $('body').find(":last").after(" <div class='spacer'></div><div id='nav_menu_wrapper'><div class='nav_menu'>"); }); 

you can use jquery inject <link> tag href pointing wherever serve script:

$('head').append(     $('<link/>', {href: '//path.to/your/stylesheet.css', rel: 'stylesheet'}) ); 

Comments