The $ dollar sign

后端 未结 9 1769
执笔经年
执笔经年 2020-11-29 04:16

I have something simple like this:

$(selector).append("somestuff");

But since I\'m going to reuse the selector I cache it with:

9条回答
  •  有刺的猬
    2020-11-29 04:41

    In this case, $selector is an example of Hungarian notation. It is there so that you know that $selector is a jQuery object.

    If you make it your custom to always have jQuery objects start with $ if you suddenly use one wrong it will look wrong which will help you find a problem in your code.

    The language couldn't care less. They could have just as well named the jQuery function J or anything else; the $ is not a special symbol.

提交回复
热议问题