Jquery 冲突?
我正在尝试在我的应用程序中使用jquery,我之前已经在多个位置使用过一些jquery。现在我想为我的标签演示再添加一个广告。我正在这样练习..
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js">
</script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js">
</script>
</head>
<body>
<script>
$(function() {
$( "#my_tabs" ).tabs({
event: "mouseover" //click
});
$.noConflict();
});
</script>
但是当我使用这个时,我之前与同一页面的其他部分一起使用的jquery停止工作。我认为这两个jquery有冲突。我尝试使用 $.noConflict() 来完成此操作,如上面的代码所示,但它不起作用我认为我错过了一些东西。请帮忙...
I am trying to use a jquery in my application where i have already used some jqueries before at several locations. how ever now i want to ad one more for my tab presentation. I am practicing it like this..
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js">
</script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js">
</script>
</head>
<body>
<script>
$(function() {
$( "#my_tabs" ).tabs({
event: "mouseover" //click
});
$.noConflict();
});
</script>
But when i use this my previous jquery that i have used with another part of the same page stop working. I think the 2 jqueries have conflicts. I tried to do it with $.noConflict() as shown in above code and its not working I think that I am missing Something. Please help ...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的代码应该是这样的:
或者,
后者称为自调用匿名函数,用于将
$
映射到jQuery
对象,这意味着您可以使用$
安全地进入。Here is how your code should be:
Or alternatively,
The later is known as self-invoking anonymous function and used to map
$
tojQuery
object which means you can use$
inside safely.用法示例:
usage example: