Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery.Deferred exception: $ is not a function

I'm facing a strange issue with jQuery. I've created a custom snippet of code in elementor custom code and I'm loading it at the end of the body. I'm trying to open a popup from an accordion when an anchor tag is clicked but I'm getting these errors in the console

Uncaught TypeError: $ is not a function

jquery.min.js?ver=3.7.1:2 jQuery.Deferred exception: $ is not a function TypeError: $ is not a function`

this is the snippet of code

<script>
jQuery(document).ready(function(){
    $('#ipopup').on('click', function(){
            window.elementorProFrontend.modules.popup.showPopup({ id: 16625 });
    });
});
</script>

I have not used jQuery for a long time, how I can fix this problem?

like image 525
OHICT Avatar asked Sep 02 '26 01:09

OHICT


1 Answers

<script>
jQuery(document).ready(function($) {
    // Use $ inside the function scope as an alias for jQuery
    $('#ipopup').on('click', function() {
        window.elementorProFrontend.modules.popup.showPopup({ id: 16625});
    });
});
</script>

Pass jQuery object as a parameter ($) to the document.ready function, allowing you to use $ as an alias for jQuery within the scope of this function.

like image 128
Adil Avatar answered Sep 04 '26 14:09

Adil



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!