jquery破坏了其他脚本

jquery breaks other scripts

本文关键字:脚本 其他 坏了 jquery      更新时间:2023-09-26

首先,我对脚本一无所知,几乎不懂HTML。

不管怎样,我发现了这个:

    <script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
    <script type="text/javascript">
    function showThis2(x) {
      $("#NContent").html(  $("#"+x).html());
    };
    </script>
<a href="#Nut" onclick="showThis1('1');">1</a>
<a href="#Nut" onclick="showThis2('2');">2</a>
<div id="NContent"></div>

这完全可以正常工作,但它破坏了我网站上的其他脚本。

我在谷歌上搜索了我应该使用的:

var jQuery_latest = $.noConflict(true);

但我无法使它工作,我可能没有正确放置它或其他什么。

希望有人能帮忙。

谢谢!

使用时

var jQuery_latest = $.noConflict(true);

$变量不再是jQuery。您必须将脚本更改为

<script type="text/javascript">
    function showThis2(x) {
      jQuery_latest("#NContent").html(jQuery_latest("#"+x).html());
    };
</script>

注意不要多次添加负载jQuery,它也可能会产生冲突。

听起来好像已经加载了两次jQuery。尝试删除第一个脚本标记,看看会发生什么。

此外,jQuery 1.3.2实际上已经过时了。1.10.2是最新的。