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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:22:48+00:00 2026-05-26T02:22:48+00:00

I have this current script which works great for changing class names $(‘#mydiv li

  • 0

I have this current script which works great for changing class names

    $('#mydiv li a').click(
    function(e) {
      e.preventDefault(); // prevent the default action
      e.stopPropagation(); // stop the click from bubbling
      $(this).closest('ul').find('.current').removeClass('current');
      $(this).addClass('current');

    });

              <ul>
                   <li><a href="" class="current">one</a></li>
                   <li><a href="#">two</a></li>
                   <li><a href="#">three</a></li>
                   <li><a href="#">four</a></li>
               </ul>

Now i have 4 diffrent div’s area

    <div id="first">some text and form</div>
    <div id="second">some text and form</div>
    <div id="third">some text and form</div>
    <div id="last">some text and form</div>

which i have hidden with jquery like $(#second).hide(); $(third).hide();$(last).hide();
so when page loads one #first is visible on page, if i click on second href from above list item i wants to initialize $(second).show(); and hide other 3 div’s, if i click on 3rd href from above list i wants to display $(#third).show(); and so on.

So from 4 div’s only one should be visible on page.
can someone help me to show how i can achieve it with above code?
Thanks

  • 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-26T02:22:48+00:00Added an answer on May 26, 2026 at 2:22 am
    $('#mydiv li a').click(function(e) {
      $(this).closest('ul').find('.current').removeClass('current');
      $(this).addClass('current');
    
      $(this.href).show().siblings().hide();
      return false;
    });
    
    
    <ul>
      <li><a href="#first" class="current">one</a></li>
      <li><a href="#second">two</a></li>
      <li><a href="#third">three</a></li>
      <li><a href="#last">four</a></li>
    </ul>
    
    <div id="first">some text and form</div>
    <div id="second">some text and form</div>
    <div id="third">some text and form</div>
    <div id="last">some text and form</div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some user controls, I have this binding: AppLanguage={Binding Path=ApplicationLanguage, Source={x:Static Application.Current}} This works
i have this html menu: <ul id='main'> <li class='active current' id='lighty'> <a href='/'>Lighty</a> <ul>
I have three current thoughts on how to do this: re-implement AuthenticationService, which uses
I have a shell script which copies a few files to the current directory,
I have a plugin i created which works great when there is only one
I have this code, which uses ob_start php function. Which basically puts the echoed
I have the following hover script which works on my nav link images: $(nav
As a beginner in Ocaml, I have this current working code: ... let ch_in
I have this code: Dim pathString As String = HttpContext.Current.Request.MapPath(Banking.mdb) Dim odbconBanking As New
I am having a bit of difficulty with this current code I have set

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.