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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:53:25+00:00 2026-05-28T04:53:25+00:00

I have this html structure: <div id=home> <div class=section_header> <h1 class=left data-target=newest><?=lang(‘home_newest’);?></h1> … </div>

  • 0

I have this html structure:

<div id="home">

    <div class="section_header">
        <h1 class="left" data-target="newest"><?=lang('home_newest');?></h1>
        ...
    </div>
    <div id="newest">
        ...
    </div>

    <div class="section_header">
        <h1 class="left" data-target="best"><?=lang('home_newest');?></h1>
        ...
    </div>
    <div id="best">
        ...
    </div>

</div>

What I am trying to do is a toggle/show&hide function to work on click .section_header > h1 to show the div with the id defined in data-target inside h1 tag and hide the others, but always having one open and the #newest open by default on page load.

I have tried:

$('.section_header h1').click(function(){
    var selected = $(this).data('target');
    //$('#'+selected).hide().filter('#'+selected).show();
    $('#home > #'+selected).hide();
}).first().click();

The commented line doesn’t work, but the .hide only it does.

I found this: http://www.learningjquery.com/2007/02/more-showing-more-hiding and thought it could work but I didn’t succeed to tell it which div to close and show

Edit:
There is one more thing, how can it be done that when clicked on the visible div to close it and open the next one?

  • 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-28T04:53:26+00:00Added an answer on May 28, 2026 at 4:53 am

    Try this one: http://jsbin.com/unetay/3/edit

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

Sidebar

Related Questions

Suppose I have this HTML structure: <div class=a> <div class=floated-left>...</div> <div class=floated-left>...</div> </div> I
I have a html structure like this.. <div id=divid> <ul id=ulid> <li style=margin-left: 8px>
I have this HTML structure: <div class=start> <div class=someclass> <div class=catchme> <div=nested> <div class=catchme>
i have html structure like this <div> <span class=ic> <span class=ic>12345</span> </span> </div> i
I have this simple html structure: <div id=mainbody> <div id=main> ... </div> <div id=left>
I have this basic HTML structure: <fieldset> <input/> <label></label> <div class=toggle_box> <div class=switch></div> </div>
I have a html structure like this: <div class=one> <div id=two> <h2>Any</h2> <h4>Any</h4> </div>
I have an HTML structure in this format: <div class=wrap> <div class=name></div> <div class=content>
I have a structure that looks like this: http://peterned.home.xs4all.nl/examples/csslayout1.html - where the middle div
I have this HTML structure <img width=25 height=25 src=/data/apple_logo.jpg alt=Chocolate /> <input class=cake_checkboxes style=vertical-align:

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.