Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to replace 'dollar' sign with another character used in jquery?

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");
like image 394
user2609417 Avatar asked Dec 03 '13 10:12

user2609417


People also ask

Can we replace dollar sign in jQuery?

Another way to avoid the need to spell jQuery every time you apply the script is by entering no conflict mode. This allows you to replace the dollar sign with the j$ alias but you can define a different symbol later.

Which jQuery method helps you replace dollar with keyboard?

Explanation: Instead of using the $ (dollar sign), we can use jQuery as a function name. For example: jQuery(document). ready(function() { jQuery("p").

What is '$' in jQuery?

The jQuery object :) From the jQuery documentation: By default, jQuery uses "$" as a shortcut for "jQuery" So, using $("#id" ) or jQuery("#id") is the same.

Can we use any other symbols instead of in jQuery?

In jQuery's case, $ is just an alias for jQuery, so all functionality is available without using $ . If you need to use another JavaScript library alongside jQuery, return control of $ back to the other library with a call to $. noConflict() .


2 Answers

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);
like image 101
georg Avatar answered Nov 15 '22 00:11

georg


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()

like image 27
Rituraj ratan Avatar answered Nov 15 '22 00:11

Rituraj ratan