Perform a Jquery action by clicking a link

Asked

Viewed 517 times

0

I want you to click on some of the links in the menu of my site, run scrollTop.

$(document).ready(function() {
    $(".menu-topo a").click(function() {
        $('html, body').animate({
            scrollTop: (400)
        }, 2000);
    });
});

It turns out that the effect is happening before and soon after changes page, what I really want is when I click on some of the links that is in the menu, the page click and then the effect happens.

  • put this function on the pages q wants the effect, and take the animate from within the click

  • Is the content AJAX or redirects? If it is redirected, you have to take the "click" event, and rotate when you load the page

  • is by redirecting even, and how do I do this Lucas ? my knowledge is still limited in Jquery

  • 1

    Guy like I said, select the pages on q you want the animation to be performed and put your animate within the $(document).ready() of this page. So when this page loads will perform the animation

  • but in that case the effect will happen twice, when I click it will start and will be interrupted, and as I am using Wordpress by default is already on all pages the same code

  • The page menu does not need any function. Create a file .js for the pages q wants this animation and take the event click

  • Look at this here. http://answall.com/questions/30703/volta-homeda-p%C3%A1gina

  • Just put that animate out of the click and see if that’s what you want, because then it will run when load the page

  • Well did I took event clicking with the mouse and put inside a wordpress function that checks if this on the home page. With this any page other than the home page will receive the effect of sliding a few pixels below. <? php wp_reset_query(); if (!is_home()) { ? > <script type="text/javascript"> $(Document). ready(Function() { $('html, body').Animate({ scrollTop: (200) }, 1000); }); </script> <? php } Else { ? > <? php } ?>

Show 4 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.