[Resolved] jQuery only works when I'm logged in

Home Forums Support [Resolved] jQuery only works when I'm logged in

Home Forums Support jQuery only works when I'm logged in

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #954667
    Antonio

    Hi,

    I am using GP premium to add Hooks to a website. In the specific I have small script in the wp_head and usually I use the same on other projects and it always works.

    I realised that the script is loaded only when I am logged in WordPress.

    I try to deactivate all the plugins (security and cache plugins etc.) but is not solving the problem.

    This is the script:

    <script>
    jQuery(document).ready(function($){
    $(document.body).on("mouseenter mouseleave", ".kg-1", function() {
    $('.w_01').toggle();
    });
    
    $(document.body).on("mouseenter mouseleave", ".kg-2", function() {
    $('.w_02').toggle();
    });
    
    $(document.body).on("mouseenter mouseleave", ".kg-3", function() {
    $('.w_03').toggle();
    });
    
    $(document.body).on("mouseenter mouseleave", ".kg-4", function() {
    $('.w_04').toggle();
    });
    
    $(document.body).on("mouseenter mouseleave", ".kg-5", function() {
    $('.w_05').toggle();
    });
    
    $(document.body).on("mouseenter mouseleave", ".kg-6", function() {
    $('.w_06').toggle();
    });
    
    $(document.body).on("mouseenter mouseleave", ".kg-7", function() {
    $('.w_07').toggle();
    });
    
    $(document.body).on("mouseenter mouseleave", ".kg-8", function() {
    $('.w_08').toggle();
    });
    
    $(document.body).on("mouseenter mouseleave", ".kg-9", function() {
    $('.w_09').toggle();
    });
    
    $(document.body).on("mouseenter mouseleave", ".kg-10", function() {
    $('.w_10').toggle();
    });
    
    $(document.body).on("mouseenter mouseleave", ".kg-11", function() {
    $('.w_11').toggle();
    });
    
    $(document.body).on("mouseenter mouseleave", ".kg-12", function() {
    $('.w_12').toggle();
    });
    
    $(document.body).on("mouseenter mouseleave", ".kg-13", function() {
    $('.w_13').toggle();
    });
    
    $(document.body).on("mouseenter mouseleave", ".kg-14", function() {
    $('.w_14').toggle();
    });
    
    $(document.body).on("mouseenter mouseleave", ".kg-15", function() {
    $('.w_15').toggle();
    });
    
    $(document.body).on("mouseenter mouseleave", ".kg-16", function() {
    $('.w_16').toggle();
    });
    
    $(document.body).on("mouseenter mouseleave", ".kg-17", function() {
    $('.w_17').toggle();
    });
    
    $(document.body).on("mouseenter mouseleave", ".kg-18", function() {
    $('.w_18').toggle();
    });
    
    $(document.body).on("mouseenter mouseleave", ".kg-19", function() {
    $('.w_19').toggle();
    });
    
    $(document.body).on("mouseenter mouseleave", ".kg-20", function() {
    $('.w_20').toggle();
    });
    
    $(document.body).on("mouseenter mouseleave", ".kg-21", function() {
    $('.w_21').toggle();
    });
    
    $(document.body).on("mouseenter mouseleave", ".kg-22", function() {
    $('.w_22').toggle();
    });
    	
    });
    </script>

    Thats the error I get when I am not logged in:

    Uncaught ReferenceError: jQuery is not defined at (index):61

    Do you have any tips?

    Thanks in advance!!!

    #954727
    David
    Staff
    Customer Support

    Hi there,

    try moving your script to the WP_footer hook as your site currently calls jQuery in the footer.

    #954734
    Antonio

    Hi David,

    Unfortunately is not working.

    I already tried and this is the error I get:

    Uncaught ReferenceError: jQuery is not defined at (index):2038

    I really can’t explain why.

    #954752
    David
    Staff
    Customer Support

    Issue: jQuery is being called near to the very bottom of the wp_footer so the script needs to come after that. You can do this by increasing the Hook Priority – try 25 or higher.

    #954759
    Antonio

    Hi David,

    Wow that’s great. Now is working properly.

    Thanks a lot for you support.

    You guys are awesome!

    #954762
    David
    Staff
    Customer Support

    You’re welcome.

    #1130905
    Muhammad

    I was facing the same problem. Thank you Antonio for asking this question and thank you David for the rescue ๐Ÿ™‚

    #1130936
    David
    Staff
    Customer Support

    Glad we could be of help ๐Ÿ™‚

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.