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 6607655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:31:35+00:00 2026-05-25T19:31:35+00:00

I have a navigation animation that is being applied to elements with the js

  • 0

I have a navigation animation that is being applied to elements with the “js” class – via a css background. I don’t want this animation to occur on the link for the current page (a class “current” is being echo’d out by PHP to the current page).

So basically the page your on (current page) link in the main nav will have a class of current, the others a class of js – and get the animation. How do apply that logic in a funciton? I can do it via css background but want to do it in js.
Here is working js used in combination with css for desired look:

 $(function() {
    $("ul#mainNav li a").addClass("js");
        $("ul#mainNav li a").hover(
          function () {
            $(this).stop(true,true).animate({backgroundPosition:"(0 0)"}, 200);
            $(this).animate({backgroundPosition:"(0 -5px)"}, 150);
          },
          function () {
            $(this).animate({backgroundPosition:"(0 -130px)"}, 200);

          }
        );
    });

What I’m trying to no avail:

$(function() {
    if($("ul#mainNav li a").hasClass("current")) {
    //do nothing
    } else {
    $(this).addClass("js")
    }

//rest of animation function

});

});
  • 1 1 Answer
  • 0 Views
  • 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-25T19:31:35+00:00Added an answer on May 25, 2026 at 7:31 pm

    There are several ways to approach this. If you need the selector you have for other things, you can do it like this:

    $(function() {
        $("#mainNav li a").each(function() {
            if (!$(this).hasClass("current")) {
                $(this).addClass("js")
            }
        });
    
    //rest of animation function
    });
    

    If you don’t need that whole selector for other things, then you can do it more simply like this:

    $("#mainNav li a").not(".current").addClass("js");
    

    Note, I’ve removed the ul from the start of your main selector as it is not required since ids are unique.

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

Sidebar

Related Questions

I want to have a TabBar controller inside a navigation controller. So that when
here's a gimme for anyone that knows jQuery: I have a navigation <ul class=nav>
I have a navigation view with a cell that has something as simple as
I have a navigation controller which also has a table view. I want to
I have a navigation bar that has two dropdowns (as nested ul's). I'm trying
I have a webpage at http://www.optiekmeulemeester.be/normal with sliding navigation. This happens with the following
I have the following code that adds a background worker into a VB.net WPF
I have View Controller with a (navigation controller) that can flip between 2 views
I have a popover that gets loaded with a navigation controller, which displays the
I have view that has a webview and a UIToolbar. I want to create

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.