regex - Change head <link href=""> to another DIRECTORY by jquery/javascript -


i want change head link href="..." css files target directory jquery/javascript, following:

it's this:

<link href="css/style.css"> 

i want change this:

<link href="../css/style.css"> 

my try is:

$(document).load(function () { function headlinkschange() {     $('head link').each(function () {         var newurl = $(this).attr('href').replace("css", "\.\.\/css");         $(this).attr('href', newurl);     }); } headlinkschange(); }); 

how can that?

thanks

you can way using function overload of attr method of jquery object. no need of regex, string concatenation. there no need of function here, suppose.

$('head link').attr('href', function(_, src){     return "../" + src; }); 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -