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】$関数の重複

0
Posted at

参考

scriptタグとcssタグのsrcの参考先が、静的コードと動的コードが混在しまくって、
いわゆるスパゲッティコード化して「$関数が未定義(undefined)」が発生した状態に行った対処法。
おそらく、Jquery.jsの定義が数か所あった為に発生したと思われる。

本来であれば根本から修正すべきだが、
工数が膨大に膨れ上がりそうだったのと、リスクが大きそうだったので、以下の苦肉の策。

「jQuery.noConflict();」を定義して、「(function($) {」~「})(jQuery);」で囲う。
これで最初に読み込みされた「Jquery.js」が採用される模様。

jQuery.noConflict(); 
(function($) {
    //ボタン押下イベント
    $('#btnExec').click(function(){
        window.hrer = '../menu.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?