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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:35:06+00:00 2026-06-18T02:35:06+00:00

if clicked on first ‘a’ tag then I add ‘selected’ class to this by

  • 0

if clicked on first ‘a’ tag then I add ‘selected’ class to this by jquery second ‘a’ tag then first tab overlapped on second one. I do not want to change its position. Just want to add z-index to selected tab.

Whats wrong in my code:

html:

<div class="kumar-tabs">
            <ul>
                <li><a href="javascript:void(0)" id="residential">Residential</a></li>
                <li><a href="javascript:void(0)" id="commercial" >Commercial</a></li>
                <div class="kumar-links-bottom-line"></div>
            </ul>
            <div class="residential" style="">
                <div class="kumar-projet-row">
                    <span class="kumar-bullet"></span>
                    <a href="project-overview.php?PID=9" class="kumar-project-name">Kumar Surabhi</a>
                    <span class="kumar-project-desc">- Swargate</span>
                </div>

            </div>
            <div class="commercial" style="display: none;">
                <div class="kumar-projet-row">
                    <span class="kumar-bullet"></span>
                    <a href="project-overview.php?PID=21" class="kumar-project-name">Connaught Place</a>
                    <span class="kumar-project-desc">- Bund Garden Road</span>
                </div>      
            </div>
</div>

css:

.kumar-tabs {
overflow: hidden;
}
.kumar-tabs ul {
position: relative;
overflow: hidden;
margin: 7px 0;
}
.kumar-tabs li {
float: left;
}
.kumar-tabs li a {
display: block;
margin: 0 5px;
background: #cacaca;
border: 1px solid #a2a2a2;
border-bottom: none;
padding: 5px;
color: #606060;
}
.kumar-tabs li a.selected {
background: #ffffff;
position: absolute;
z-index: 1;
color: #2f2f2f;
}
.kumar-links-bottom-line {
background: #a2a2a2;
height: 1px;
width: 100%;
position: absolute;
bottom: 0px;
}

Jquery:

$(document).ready(function(){
    $('#commercial').removeClass('selected');
    $('#residential').addClass('selected'); 
    $('.commercial').hide();
    $('.residential').show();

    $('#residential').click(function(){
        $('#commercial').removeClass('selected');
        $('#residential').addClass('selected'); 
        $('.commercial').hide();
        $('.residential').show();   
    });
    $('#commercial').click(function(){
        $('#residential').removeClass('selected');  
        $('#commercial').addClass('selected');
        $('.residential').hide();
        $('.commercial').show();
    });
});

Thanking You.

  • 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-18T02:35:07+00:00Added an answer on June 18, 2026 at 2:35 am

    By “I do not want to change its position” I think you mean the left and top position.
    In your CSS; change the position value of the selected to relative instead of absolute.

    .kumar-tabs li a.selected {
        background: #ffffff;
        position: relative; /* « or remove this line */
        z-index: 1;
        color: #2f2f2f;
    }
    

    Here is a demo fiddle.

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

Sidebar

Related Questions

$(.blok).newWindow({ windowTitle:Example1, ajaxURL:Action.php?task=BlokDuzenleFormGetirBlokId=+$(.blok).attr('id') }); when first clicked on blok class a href, newWindow loads
So, i have such problem: first time, then the <a> get clicked e.preventDefault() isn't
i cant access clicked object(this) parent's class.. click same elements and different returns? this
This code is working. but the problem is when NO_OPTION is selected then the
This is actually two questions: The first relates to my program The second is
I'm trying to pass this from a clicked span to a jQuery function that
I want to hide an element after it is first clicked (using jQuery), so
The custom_value of place_id is set to whichever row I click first. Subsequent clicked
I have an image button that when clicked the first time it just seems
With the following html and jQuery, if I click the first anchor multiple times

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.