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

后端 未结 3 1429
忘掉有多难
忘掉有多难 2021-01-05 22:43

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

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

3条回答
  •  灰色年华
    2021-01-05 23:04

    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.

提交回复
热议问题