jQuery Uncaught TypeError $ is not a function (only working on few pages)

前端 未结 1 1922
自闭症患者
自闭症患者 2021-01-22 02:16

I am quite new to jQuery and I am trying to include a toggle-nav script to my Joomla template. I included the latest version of jQuery and my .js file where the function is stor

1条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-22 02:46

    Your script is probably conflicting with mootools which is common depending on your joomla version and script setup. Try the following:

    // You might need this, usually it's autoloaded   
    jQuery.noConflict();
    
    // Replace $ with jQuery
    jQuery(document).ready(function() {
        jQuery('.toggle-nav').click(function() {
          jQuery('.navigation').toggleClass('show');
        });
    });
    

    0 讨论(0)
提交回复
热议问题