Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5995827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:01:00+00:00 2026-05-23T00:01:00+00:00

i have a site with a simple PHP-Navigation (using $_GET-Variables). HTML-code for navigation links

  • 0

i have a site with a simple PHP-Navigation (using $_GET-Variables).

HTML-code for navigation links (they are floated right):

<a href="index.php?main=test1" class="menuelement">Test 1</a>
<a href="index.php?main=test2" class="menuelement">Test 2</a>
<a href="index.php?main=test2" class="menuelement">Test 3</a>

Simple PHP-codeblock to include pages:

if(!isset($_GET['main'])) {
    $page = "home";
} else {
    $page = $_GET['main'];
}
include($page.".php");

Both codeblocs are on index.php.

The menu-elements are animated with jQuerys .animate() like this (the code is between $(document).ready):

$('.menuelement').hover(function () {
    if ($(this).hasClass('clicked') == false) {             
        $(this).stop(true, false).animate({
            'padding-right': '80px'
        }, 900, 'easeOutBounce');
    }
}, 
function () {
    if ($(this).hasClass('clicked') == false) {     
        $(this).stop(true, false).animate({
            'padding-right': '0px'
        }, 900, 'easeOutBounce');
    }
}
).click(function() {
    if ($(this).hasClass('clicked') == true) {
        //Don't do anything.
    } else {
        $('a.clicked').animate({
            'padding-right': '0px'
        }, 900, 'easeOutBounce');
        $('a.clicked').removeClass('clicked');

        $(this).addClass('clicked');
        $(this).stop(true, false).animate({
            'padding-right': '80px'
        }, 900, 'easeOutBounce');
    }
});

What happens is that the hovered menuelement slides to the left (remember: it’s floated right), on mouseout it slides back. On click, it stays where it is and gets a class to mark that it’s clicked. If you click on another menuelement, the one which was clicked before slides back and the new one stays slided out. All this is done with addClass, removeClass and some if-else-statements … quite simple. If the a-Tags of the links doesn’t have any linktargets, e. g. only the hash sign () everything works fine.

But as soon as the links have a target (e. g. ), the jQuery-animation starts again when a menuelement is clicked, because index.php is kind of reloaded. The result is that the clicked menuelement won’t stay slided out.

I know I could (and I already did) load some content with e. g. .load() into a div. But I don’t want to do that concerning SEO and some other aspects.

Is ther any way to use the PHP-navigation and jQuerys fantastic .animate(), without “reloading” the animation each time a link is clicked? Maybe there are some PHP or jQuery hints that I don’t know.

Thank you for any help!

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T00:01:01+00:00Added an answer on May 23, 2026 at 12:01 am

    You can use event.preventDefault() to stop the browser from following the link and use a complete callback function in animate to load the linked-to page after the animation is done.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a rather simple site (minimal JS) with plain html and CSS. It
I have a site that has a simple HTML button in a form. All
I have a simple Tray icon program that opens a site using System.Diagnostics.Process.Start(URL) And
I have a simple php site that I built, but for some reason my
We have a simple PHP site. It is getting hit quite a bit. We
I have a simple site to develop and would like to learn PHP as
I have a simple update set php sql function on my site where I
Imagine that you have a simple site with only 2 pages: login.aspx and secret.aspx.
I have a relatively simple site that I'm working up for an intranet environment.
I have a simple PowerShell script that uses WMI to create a web site

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.