不确定如何实现noConflict()代码 [英] Unsure of how to implement the noConflict() code
问题描述
我目前正在设计一个网站,我正在使用jQuery ScrollTo 插件,该插件使用 jQuery 1.6.2 库。作为网站的一部分,我需要创建一个Ajax联系表单(我需要确保它不会将用户带到另一个页面,因为它是一个垂直滚动的站点,其中所有内容都在一个页面上)。我能找到的唯一的jQuery Ajax表单使用 jQuery 1.3.2 。我已经对 noConflict()模式进行了一些阅读,但是在Java / PHP中有点像初学者,我真的不确定如何使用它。
I am currently designing a website where I am using the jQuery ScrollTo plug-in, which uses the jQuery 1.6.2 library. As part of the website, I am required to create an Ajax contact form (I need to make sure it does not take the user to another page, as it's a vertically scrolling site in which all content is on one page). The only jQuery Ajax form I could find uses jQuery 1.3.2. I've done a little bit of reading around about the noConflict() mode, but being a bit of a beginner in Java/PHP, I'm really not sure of how to use it.
我当前的< head>
代码如下:
<script type="text/javascript" src="jquery/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="form/js/jquery-1.3.2.js"></script>
<script type="text/javascript" src="jquery/jquery.scrollTo.js"></script>
<script type="text/javascript" src="form/js/js.js"></script>
前两行调用两个jQuery库,第二行是特定代码滚动和表单。
The first two lines are calling on the two jQuery libraries, and the second ones are the specific codes for the scroll and the form.
我真的不清楚如何使用noConflict这些代码,有人可以帮助我吗?我知道这个问题之前已被问过很多次了,但我只是对它感到困惑!
I'm really unclear of how to use noConflict with these codes, can someone please help me? I know this question has been asked a lot of times before, but I'm just confused by it!
请注意我在页面内调用我的库,但是没有JS实际上是在主页文档中写的,它全部在其他文件中,例如:form / js / js.js 。
Please note that I call on my libraries within the page, but no JS is actually written WITHIN the homepage document, it's all in other files, eg: form/js/js.js.
谢谢非常感谢任何可以帮助我的人。
Thanks a lot to anyone that can help me, very much appreciated.
推荐答案
试试这个:
var jq = jQuery.noConflict();
(function($) {
$(function() {
// more code using $ as alias to jQuery
});
})(jq );
这篇关于不确定如何实现noConflict()代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!