找到你要的答案

Q:How to determine which library uses $ sign from console?

Q:如何确定从控制台中使用哪个库的符号?

I have handled a project which uses multiple JS libraries, including jQuery. Checked

 $.fn.jquery 

and it returns

Cannot read property 'jquery' of undefined

However,

 jQuery.fn.jquery

returns the jquery version, which tells me that something else is using the $ sign. Is there any way to determine if some library uses it and which one from console ?

我曾经处理过一个项目,使用多个js库,包括jQuery。选中的

 $.fn.jquery 

它返回

无法读取jQuery定义的属性

然而,

 jQuery.fn.jquery

返回的jQuery的版本,它告诉我什么是使用$符号。有没有办法确定一些库使用它和控制台中的哪一个?

answer1: 回答1:

All libraries have their own properties and methods, The better way to find is, type $ in chrome console, and try to expand till you get expected result.

jQuery has fn object which has jquery property which holds version of jQuery.

Lets say there is another library which uses $, that might has property version to get version.

The better way to use jQuery is using closure.

Here is Example.

(function($){//Here you can use $ or $$ or anything which is allowed to use as variable.

})(jQuery);

All libraries have their own properties and methods, The better way to find is, type $ in chrome console, and try to expand till you get expected result.

jQuery对象具有FN版本的jQuery jQuery物业持有。

比方说,有另一个库使用$,可能有属性版本得到版本。

使用jQuery使用闭包的更好的方式。

这里是例子。

(function($){//Here you can use $ or $$ or anything which is allowed to use as variable.

})(jQuery);
javascript  jquery