0

私は2つの異なるスクリプトを使用しています。1 つはメニュー用、もう 1 つは追加しようとしているライトボックス用です。

head セクションで両方のスクリプトを宣言しましたが、両方を同時に動作させることはできません。同時に2つの異なるjQueryバージョンを使用しようとしているため、それはわかっていますが、これを回避する方法はありますか?

<script type="text/javascript" src="js/custommenu.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

1 つ目はカスタム メニュー用で、2 つ目はKyle Schaeffer のブログから入手したライトボックス スクリプトで使用されています。

どんな助けでも大歓迎です。

ありがとう

4

2 に答える 2

0
  1. Please list all the JS files you're loading into this page. List them in the same order you load them please.

  2. Try loading only one version of jQuery and load it before all other scripts

  3. If you really need to use two version if jQuery on one page, you have to put one of them into noConflict-mode ( http://api.jquery.com/jQuery.noConflict/ ). But I then you'll have to change your script so that it will not user $ but the noConflict-variable instead (see jQuery docs).

于 2012-08-17T22:55:31.010 に答える
0

このようにページヘッダーを再配置します

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="js/custommenu.js"></script>

また、単一の「jquery.min.js」を使用してみてください

于 2012-08-17T22:01:27.617 に答える