5

How will I change the dollar sign (alias for 'jquery') used in jquery with another character. For example

$("#id").css("height","210px");

I want to change this to

*("#id").css("height","210px");
user2609417
  • 259
  • 2
  • 3
  • 9

3 Answers3

11

You cannot change $ to * because * is not a valid identifier. But you can change it to a valid one:

(function (foobar) {
    foobar("#whatever").css(....)


})(jQuery);

Given that JavaScript identifiers are unicode, you can try fancy things like for example:

(function (Ω) {
    Ω("#whatever").css(....)
})(jQuery);
Community
  • 1
  • 1
georg
  • 211,518
  • 52
  • 313
  • 390
  • +1 thanks. I thought it `* denotes All elements`. But didn't verified. So posted a wrong answer. – Praveen Dec 03 '13 at 11:32
7

dont use * as a variable name please choose valid name here i choose js

var js =jQuery.noConflict(); //by this you can do it

reference jQuery.noConflict()

Rituraj ratan
  • 10,260
  • 8
  • 34
  • 55
2

jQuery comes with a noConflict command which you can assign to a custom variable:

var jq = jQuery.noConflict(true);

This means you can do regular jQuery with your symbol:

jq.css('height', '200px');

You cannot use the asterisk (*) because it is a reserved character.

Richard Parnaby-King
  • 14,703
  • 11
  • 69
  • 129