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

  • Home
  • SEARCH
  • 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 9285457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T19:10:15+00:00 2026-06-18T19:10:15+00:00

Like this, I have two tabs, so when i click on one it’s active,

  • 0

Like this, I have two tabs, so when i click on one it’s active, logic. Now im trying to make difference between active and inactive tab, but not with .css property, but I wanna’ add specific class to clicked tab, like this:

$(".tab1").addClass('active');

but, no good. Also have in mind that I’m using external css file.

<div id="menuitem" class="tab1"></div>
<div id="menuitem" class="tab2"></div>

.active {
    width: 170px;
    height: 70px;
    float: right;
    background-color: red;
}

#menuitem {
    width: 170px;
    height: 70px;
    float: right;
    background-color: white;
}
  • 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-06-18T19:10:17+00:00Added an answer on June 18, 2026 at 7:10 pm

    First of all don’t use same id on different elements, id‘s must be unique and try this:

    jQuery:

    $('.menuitem').click(function() {
        $('.menuitem').removeClass('active');
        //removes active class from all menu items
    
        $(this).addClass('active');
        //adds active class to clicked one
    });
    

    html:

    <div id="tab1" class="menuitem"></div>
    <div id="tab2" class="menuitem"></div>
    

    css: you don’t need to define same properties to active class, just define the difference:

    .active { background-color: red; }
    
    .menuitem {
      width: 170px;
      height: 70px;
      float: right;
      background-color: white;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two websites.. (MVC applications) www.WebsiteA.com (has two tabs in it) like this..
my code is like this: i have two classes first class: public class Box<E>
Supposed I have two classes like this: public class Parent { public string Id
I have two entities like this: public class Service { public virtual int ServiceId
I have two models like this: class ClassA(models.Model): ida = models.AutoField(primary_key=True) classb = models.ForeignKey(ClassB)
I have two table like this table_CN (_id, name, phone, favorite, title) table_EN (_id,
I have two models like this: class OptionsAndFeatures(models.Model): options = models.TextField(blank=True, null=True) entertainment =
Suppose I have two functions which look like this: public static void myFunction1(int a,
i have two arrays like this first array Array ( [0228] => Array (
So I have two multiple select boxes like this <select id=foo multiple=multiple> <option value=1>Option

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.