AkiraYamaokaNC
AkiraYamaokaNC

Reputation: 360

jQuery dynamic css changing

Why does the jquery not working in Opera and Chrome?

 <script language="JavaScript">
     $('link[href="includes/styles.css"]').attr("href", "includes/new_styles.css");
     $('link[href="includes/jmesa/jmesa.css"]').attr("href", "includes/jmesa/new_jmesa.css");   
 </script>

Upvotes: 1

Views: 394

Answers (2)

Jai
Jai

Reputation: 74738

Try this out in doc ready: http://jsfiddle.net/YRC4N/

$(function(){
   $('link[href$="styles.css"]').attr("href", "includes/new_styles.css");
   $('link[href$="jmesa.css"]').attr("href", "includes/jmesa/new_jmesa.css");

   $('link').each(function () {
      console.log($(this).attr('href'));
   });
});

Upvotes: 1

Gaurav Pandey
Gaurav Pandey

Reputation: 2796

Try:

<script language="JavaScript">
 $('link[href*="includes/styles.css"]').attr("href", "includes/new_styles.css");
 $('link[href*="includes/jmesa/jmesa.css"]').attr("href", "includes/jmesa/new_jmesa.css");   
 </script>

Upvotes: 0

Related Questions