William
William

Reputation: 6610

Chrome Doesn't Accept jQuery Symbol ($)

Not a problem as such but during development I noticed that Chrome doesn't accept the '$' symbol often used instead of 'jQuery'. But runs fine when 'jQuery' is used.

Noticed this with using Chromes developer tools and thought it was odd, anyone any ideas why?

Upvotes: 1

Views: 129

Answers (3)

Arun Prasanth.G
Arun Prasanth.G

Reputation: 51

$ is a shorthand for jquery. Now, if some other libraries also uses $ along with jQuery, there occurs collisions in the usage of $.

It can be resolved by the following the below:

<script src="mylibrary.js" ></script> 
<script src="jquery.js"></script> 
<script>
    jQuery.noConflict(); 
</script>

Now after the first library jQuery takes full control over $, then the jQuery.noConflict() freesup the usage of $. But now in your custom js whenever you want to make use of a jQuery method you can't use jQuery, you must use $.

Upvotes: 0

vivek
vivek

Reputation: 2004

It's not problem with chrome. It's due to jquery conflict. $.noConflict() fixes this.

Upvotes: 3

Naftali
Naftali

Reputation: 146302

Works fine for me:

Make sure you have no other framework (that uses $) loaded on the page.

Upvotes: 2

Related Questions