0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

jQuery読み込みに関するメモ

Posted at

jQuery読み込み順番についてのメモをして行きたいと思います。

関連するエラー

uncaught referenceerror: jquery is not defined

こんなエラーが出た場合に疑いたいことは

  1. 読み込み順序
  2. 多重読み込み

これを疑いたくなります。

読み込み順序

まずこのケースです。

<html>
<head>
<script>jQuery(functrion)(){
alert('fdas');
})</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
</head>
<body>
</body>
</html>

この場合には、jQuery読み込まれる前にjQueryの機能を利用しようとするので、jQueryが見つからないエラーが出ます。

uncaught referenceerror: jquery is not defined

多重読み込み

意図せずにこのケースに陥る場合があります。例えばWordPressだとテーマで読み込まれていることに気が付かずに、
自分でもjQueryを読み込んでしまうといった場合に発生します。バージョンが違いで、古い方で定義されていない関数を利用すると、
エラーになってしまいます。

Uncaught TypeError: jQuery(...).ex is not a function
    at

こんなエラーが出ます。

<html>
<head>
<script>
jQuery(functrion)(){
jQuery.ex('fdas');
})
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> ### versionが違う
</head>
<body>
</body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.n.m/jquery.min.js"></script> ### versionが違う
</html>

この場合、下の方が有効になるので、現行バージョンよりも新しい場合、または古い場合に、
意図した関数が利用できずにエラーになる場合があります。

【jQuery】プログラム動かない時に確認すること

0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?