Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #451186

    Hello,

    I’ve been having an issue trying to load my custom jQuery into my enfold child theme. I’ve looked on this forum and tried enqueue techniques but it doesn’t work. This is my code in question and is being loaded off a script.js

    var mainbottom = $('.apmenu').offset().top;
    
    $(window).on('scroll',function(){
    
        stop = Math.round($(window).scrollTop());
        if (stop > mainbottom) {
            $('.apmenu').addClass('past-main');
        } else {
            $('.apmenu').removeClass('past-main');
        }
    });
    
     $(window).load(function() {
            var theHash = ".apmenu";
            $("html, body").delay(1200).animate({scrollTop:$(theHash).offset().top}, 500);
          });
    #451190

    Hi hostadmin!

    Please add following code to Functions.php file in Appearance > Editor

    function add_custom_code(){
    ?>
    <script>
    var mainbottom = jQuery('.apmenu').offset().top;
    
    jQuery(window).on('scroll',function(){
    
        stop = Math.round(jQuery(window).scrollTop());
        if (stop > mainbottom) {
            jQuery('.apmenu').addClass('past-main');
        } else {
            jQuery('.apmenu').removeClass('past-main');
        }
    });
    
     jQuery(window).load(function() {
            var theHash = ".apmenu";
            jQuery("html, body").delay(1200).animate({scrollTop:jQuery(theHash).offset().top}, 500);
          });
    </script>
    <?php
    }
    add_action('wp_footer', 'add_custom_code');

    Best regards,
    Yigit

    #451712
    This reply has been marked as private.
    #452790

    Hi!

    I can see your script loading fine in source code but when i try to check the console, my browser crashes. Please consider to hire a freelance developer to check your code and to fix it

    Cheers!
    Yigit

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