Custom jQuery code in Elementor page is not working on Mac os. On Windows browser work fine.

I make small jQuery script for tabs and put in Elementor page. On all Windows browsers is working fine, but on Mac os Safari and Crome is not working.

So on Mac i get error "jQuery is not defined"

I hope that someone can help me.

This is my code

jQuery(document).ready(function($) {
    $('.tab-item').click(function() {
        var tabId = $(this).attr('data-tab');

        // remove active class from all tabs and contents
        $('.tab-item, .tab-content').removeClass('active');

        // add active class to the clicked tab and its content
        $("#" + tabId).addClass('active');
  • Elementor related questions are offtopic here, but this is probably unrelated to that, are you declaring jQuery as a script dependency when you enqueue it? This is usually caused by scripts being loaded in the wrong order, if you've not declared jQuery as a dependency WP won't know to put the jQuery script tag before yours. If you're hardcoding the JS inline that could also cause this. How are you loading your JS code?
    – Tom J Nowell
    Commented Jul 27, 2023 at 9:38
  • HI, thank you for your help. I just check and didn't find any jQuery in my functions.php. So I add this code function crunchify_load_jquery_from_google_cdn() { if (!is_admin()) { wp_deregister_script('jquery'); wp_register_script('jquery', 'code.jquery.com/jquery-3.6.3.min.js', false, '3.6.0'); wp_enqueue_script('jquery'); } } add_action('wp_enqueue_scripts', 'crunchify_load_jquery_from_google_cdn'); And it work, but still I don't know how script work in Windows and didn't work on Mac
    – Pinky08
    Commented Jul 27, 2023 at 10:35
  • can you edit your question to explain how you added your own JS code? That jQuery code will slow down your sites frontend performance and could even cause compatibility problems with other plugins. If you need jQuery it's enough to do wp_enqueue_script( 'jQuery' ) but you need to declare it as a dependency of your script or WP won't know the correct order to print them out, and it'll be the luck of the draw as to wether it loads before or after your script breaking things
    – Tom J Nowell
    Commented Jul 27, 2023 at 11:05
  • the problem is not "does it load jQuery", it's "when it loads jQuery", the order matters
    – Tom J Nowell
    Commented Jul 27, 2023 at 11:06


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.