手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >jQuery 名称冲突的解决方法
jQuery 名称冲突的解决方法
摘要:jQuery使用名为noConflict()的方法来解决该问题。varjq=jQuery.noConflict(),帮助您使用自己的名称(比...

jQuery 使用名为 noConflict() 的方法来解决该问题。

var jq=jQuery.noConflict(),帮助您使用自己的名称(比如 jq)来代替 $ 符号。

示例:

复制代码 代码如下:

<html>

<head>

<script type="text/javascript" src="http://www.jb51.netjquery/jquery.js"></script>

<script type="text/javascript">

var jq=jQuery.noConflict();

jq(document).ready(function(){

jq("button").click(function(){

jq("p").hide();

});

});

</script>

</head>

<body>

<h2>This is a heading</h2>

<p>This is a paragraph.</p>

<p>This is another paragraph.</p>

<button type="button">Click me</button>

</body>

</html>

【jQuery 名称冲突的解决方法】相关文章:

javascript常用的方法分享

jquery控制表单输入框显示默认值的方法

jQuery实现文本展开收缩特效

jQuery实现在列表的首行添加数据

js实现两点之间画线的方法

jQuery实现首页图片淡入淡出效果的方法

jquery预加载图片的方法

jQuery实现表格行上移下移和置顶的方法

jQuery实现延迟跳转的方法

jQuery取消ajax请求的方法

精品推荐
分类导航