js报TypeError $(...) is null错误
来源:互联网 发布:淘宝tv订单是什么意思 编辑:程序博客网 时间:2024/06/04 20:10
页面中加载的一个插件给捣的鬼,是它将jquery的$方法给覆盖了。对于这个问题,现在分享两种解决方法。
(1)删冲突插件,jquery作为基础库,当然是没有理由被删了。这个方法最直接了。
(2)将jquery的$方法改名,具体改名方法如下:
1
jQuery.noConflict();
//将变量$的控制权让渡给给其他插件或库
2
jQuery(
function
(){
//不在直接使用$,而是使用jQuery
3
jQuery(
"p"
).click(
function
(){
4
alert( jQuery(
this
).text() );
5
});
6
});
当然如果你感觉jquery写起来比较累,还可以这么写:
1
var
$phpernote=jQuery.noConflict();
//自定义一个比较短快捷方式
2
$phpernote(
function
(){
//使用jQuery
3
$phpernote(
"p"
).click(
function
(){
4
alert( $phpernote(
this
).text() );
5
});
6
});
0 0
- js报TypeError $(...) is null错误
- js报TypeError $(...) is null错误,jquery失效的原因及解决办法
- js报TypeError $(...) is null错误,jquery失效的原因及解决办法
- js报TypeError $(...) is null错误,jquery失效的原因及解决办法
- TypeError document.getElementById(...) is null错误原因
- extjs调试错误 TypeError:p is null 或 TypeError: el is null
- TypeError: canvas is null
- Extjs在火狐浏览器下提示ext-all.js 中出现TypeError: b is null的错误
- TypeError: document.getElementById(...) is null
- js报错:TypeError: document.GetElementById is not a function
- js报错 :TypeError: yanzhengma is not a function
- js报错:TypeError: document.GetElementById is not a function
- [JS] TypeError: dbg is undefined 错误的解决方法
- tab布局中一直报TypeError: el is null el.addCls.apply(el, .........
- 关于引用iframe下的页面时出现TypeError: G.getComputedStyle(...) is null错误
- js编写中遇到的问题-TypeError: document.body is null
- 异常TypeError: Ext.get(...) is null
- ajaxfileupload.js结合低版本jquery报异常:TypeError: jQuery.handleError is not a function
- Multiple annotations found at this line
- sql中的replace用法
- CSS3 animation--圆圈刷新动画
- java二叉树
- 阿里云ECS服务器下挂载数据盘、JDK安装、tomcat安装
- js报TypeError $(...) is null错误
- 一个优秀IT系统管理员该有的良好习惯
- 用C++写HelloWorld
- visual studio 2015运行VC++控制台程序,如何解决提示系统找不到指定文件【解决办法】
- java 调用 ffmpeg 进行视频转换以及截图
- C++侵入式智能指针的实现
- 【腾讯Bugly经验分享】程序员的成长离不开哪些软技能?
- 动画系列(一)UIDynamic
- SDAutoLayout