LoginSignup
1
2

More than 5 years have passed since last update.

prototype.jsとjQueryを同時に使う。

Last updated at Posted at 2017-07-14

概要

prototype.jsとjQueryを同時に使おうとすると、
競合のようなものが起き、正常に動作しない場合があります。

内容

まず、呼び出し順はprototype.jsを先にします。

<script src="prototype.js"></script>
<script src="jquery.js"></script>

そして競合というのは、コード内の"$"が競合してエラーが出ます。
なので、jQuery側の"$"を"jQuery"に置き換えます。

$(function(){

});

これを

jQuery(function(){

});

このようにします。
こんなんで動くんですね。笑

補足

これで動かない場合は、
jsの読み込みを全ページ共通ではなく使用するページのみにすると上手くいくかもしれません。

1
2
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2