GoogleSearchBox

Custom Search

Tuesday, August 20, 2013

What is the dollar Sign ($) means in JQuery Or how to avoid $ collision from jquery with other languages or technologies

$ (dollar) sign in Jquery is just a method name or identifier name.

As javascript allows the $ sign as a special character including some other special characters to be used as a valid variable name (identifier) or a valid method name.

To make it simple, jQuery and some other languages (scripting or coding) has choosen this $ to use their api (methods) easily.

In jQuery, we can replace the $ sign with the word "jQuery" whenever we encounter $ collision issues with some other coding languages like JSTL (JSP, EL) or prototype etc. and it will do the trick.
Infact we can say, $ is a shortcut symbol for the "jQuery" word.

So in jQuery below code :
<script>
  $(function() {
    $( "#dialog" ).dialog();
  });
</script>

is Same as below code:
<script>
  jQuery(function() {
    jQuery( "#dialog" ).dialog();
  });
</script>



Tags:
What is the dollar Sign ($) means in JQuery ?
How to avoid $ collision from jquery with other languages or technologies ?

No comments:

Post a Comment