1

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>
3
  • 2
    does it work with other browsers? Which is the error you're getting? Commented Feb 15, 2013 at 8:56
  • It works great in FF and IE. Uncaught exception: TypeError: 'o.find' is not a function Error thrown at line 12, column 5629 in <anonymous function: find>(E) in localhost:8080/.../jquery-1.3.2.min.js: o.find(E,this[0],F); called from line 12, column 681 in <anonymous function: init>(E, H) in localhost:8080/.../jquery-1.3.2.min.js: return o(H).find(E) called from line 12, column 128 in <anonymous function: l.$>(E, F) in localhost:8080/.../jquery-1.3.2.min.js: return new o.fn.init(E,F) Commented Feb 15, 2013 at 9:04
  • 2
    @krshekhar Again; do not use code formatting for this. 'jQuery', 'Opera' and 'Chrome' are product names - they are not code. They don't need to be highlighted in any way, please. Commented Feb 15, 2013 at 9:08

2 Answers 2

1

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'));
   });
});
Sign up to request clarification or add additional context in comments.

Comments

0

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>

5 Comments

Ok so troubleshoot more, can you move the script to the lowest end of the body? or just put this script inside $(document).ready();
Hmmm.. Ok lets troubleshoot more.. first you should check in other browsers if you can get the reference of the links in your script. I mean alert($('link').length); Then if you get the right count, alert($('link[href*="includes/styles.css"]').length). if you get zero, the try with alert($('link[href$="styles.css"]').length). I am waiting here.
FF and IE have found all link tags successfully. In the Chrome console I have found this: Uncaught TypeError: Object function (E,F){return new o.fn.init(E,F)} has no method 'find'.
Ok.. so can you show somehow your page? or you can click on 'view source' and send?
Thank you for help, but I have found the trouble - prototype and jQuery conflict ($ -> jQuery)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.