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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:33:16+00:00 2026-06-14T08:33:16+00:00

By default content of first div will load then when a user click on

  • 0

By default content of first div will load then when a user click on tag,contents of that div should load.

HTML:

    <a class="first">one</a>
    <a class="second">two</a>
    <div>
       <li id="first">
           <h2>pen</h2>
           <div>
               <div>parker</div>
           </div>
      </li>
      <li id="second">
            <h2>car</h2>
            <div>Bugatti</div>
         </div>
       </li>
    </div>​

JS:

$(document).ready(function() {
    $("li#second").html();
    $("li#first").hide();
    $("a").click(function () {         
        var id = $(this).attr("class");  
        $("li#"+id).show().html();          
        $("li#second").hide();
     });
 });​

Now,when you click one,it will load but if you click two it will not load,i’m using second.hide(),how to get this working ?

  • 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-14T08:33:17+00:00Added an answer on June 14, 2026 at 8:33 am

    You’re currently binding to every a click, and then you show the corresponding li to whichever link is clicked, but you always hide #second, regardless of whether or not it is .second that is being clicked.

    You could bind them individually:

    $('a.first').click(function() {
        $('#first').show();
        $('#second').hide();
    });
    
    $('a.second').click(function() {
        $('#first').hide();
        $('#second').show();
    });
    

    Demo

    Or, if you want to address both in one listener:

    $('a').click(function() {
       var id = $(this).attr('class');
       $('#first').toggle(id == 'first');
       $('#second').toggle(id == 'second');
    });
    

    Demo

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

Sidebar

Related Questions

First of all, I do understand, that MVC 3 default template's Content folder is
I have a site that has a /sites/default/files/ directory where user content is typically
How to define that by default there should be shown the content of submenu11
I use ckeditor with a default content. Then I initialize (replace textarea) CKEditor with
Checking the datagrid example here http://www.silverlight.net/content/samples/sl4/toolkitcontrolsamples/run/default.html see the datagrid section It says that if
I am loading content with jquery.load() (1.4.2), which includes a form that I turn
I have a this Html code <select class=selectOption> <option>Analytics</option> <option>Translation</option> <option>Poll</option> </select> <div id=changingArea>
HTML: <div id=media-photo> <img src=/uploads/photos/16.jpg alt= /> </div> <a href=/uploads/photos/5.jpg class=img> <img src=/uploads/photos-thumbs/5.jpg alt=
I have this $(document).ready(function() { //Default Action $(.tab_content).hide(); //Hide all content $(ul.tabs li:first).addClass(active).show(); //Activate
I can fade in & out different div content, but I'd like that when

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.