Jam*_*ber 7 javascript console jquery
我不能为我的生活工作这一个.我有js正在运行,'container state ..'是来自页面上运行的js的控制台日志.它正在显示一个选择器,但如果我想在控制台中做任何事情,它只返回null.我假设某种程度上我在某处编写jQuery函数,好像我调用了jQuery
>>> $
function()
Run Code Online (Sandbox Code Playgroud)
这就是我调用选择器的方式
Container state 3 jQuery(div.module-carousel)
>>> $('body')
null
Run Code Online (Sandbox Code Playgroud)
jQuery使用2个名称空间,jQuery
和$
.另一个图书馆可以使用$
.尝试使用jQuery
而不是$
(假设它也没有被覆盖):
jQuery('body');
Run Code Online (Sandbox Code Playgroud)
或者在一个立即函数中包装jQuery并$
在其中使用,因此您不需要替换$
现有代码:
(function($){
//"$" in here is jQuery
//code that uses $ as jQuery will work in here
}(jQuery)); //pass in jQuery and execute
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
7629 次 |
最近记录: |