0

If there is this code inside a js file :

(function($) {
  $.cleditor = {
  ...
  };
  ...
})(jQuery);

It's the first time I see the notation $. : so what does it mean ?

4

3 に答える 3

1

これは、新しいカスタムfunctionが jQuery コアに追加されたことを意味します。

cleditor で簡単に検索すると、それが jQuery プラグインであることがわかりますが、次のように使用することになっています。

$(selector).cleditor({options}); // where selector is either an input or textarea element
于 2012-11-22T06:37:31.967 に答える
1

$. $.trim() のような jquery メソッドを呼び出すために使用されます(function($) { })(jQuery)Immediately-Invoked Function Expression簡単に言えば、無名関数での自己呼び出しです。この表記法の詳細については、こちらを参照してください

于 2012-11-22T06:36:05.750 に答える
1

デフォルトでは、jQuery は「jQuery」のショートカットとして「$」を使用します。

したがって、 $(".class") または jQuery(".class") の使用は同じです。

問題を回避するためにプラグインを作成する場合、「jQuery」を関数に渡すことができます。

function($) {

//use $ writing your plugin

}(jQuery)

現在、$.cleditor オブジェクトには、カスタム プラグインの作成と組み込み機能のオーバーライドに使用されるグローバル プロパティとメソッドが含まれています。

リンクをたどると、$.cleditor の詳細がわかります

http://premiumsoftware.net/cleditor/docs/GettingStarted.html

于 2012-11-22T06:51:15.253 に答える