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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:54:21+00:00 2026-06-13T07:54:21+00:00

I have a jquery script which replaces a div (child1 with child2) when a

  • 0

I have a jquery script which replaces a div (child1 with child2) when a href=”#1″ is selected. I have these arranged in a menu like so:

<div id=menu">
 <div class="menu_item">
      <a href="#" class="drop_menu"></a>
       <div id="parent">
          <div class="child1">Child 1 Contents</div>
          <div class="child2">Child 2 Contents</div>
       </div>
       <div id="replacepagelinks">
          <a href="#1">Replace Child 1 with Child 2</a>
          <a href="#2">Replace Child 2 with Child 1</a>
       </div>
 </div>
 <div class="menu_item">
      <a href="#" class="drop_menu"></a>
       <div id="parent">
          <div class="child1">Child 1 Contents</div>
          <div class="child2">Child 2 Contents</div>
       </div>
       <div id="replacepagelinks">
          <a href="#1">Replace Child 1 with Child 2</a>
          <a href="#2">Replace Child 2 with Child 1</a>
       </div>
 </div>
 <div class="menu_item"> etc.. </div>

Here is the jquery:

$('.child2, a[href="#1"]').hide()

Which hides the appropriate div+link.

$('#replacepagelinks a').click(function(){
    $(this).hide().siblings().show()
    var w = this.hash.replace('#', '');
    $('#parent div.child'+w).show().siblings().hide()
})

Which replaces child1 with child2 div and also changes the a href link from #1 to #2. Here i would like <a href="#1">Replace Child 1 with Child 2</a> and <a href="#2">Replace Child 2 with Child 1</a> to be in separate classes so i can have them work as ‘next’ and ‘back’ links at either side of the page, like so:

<div id="replacepagelinks">
    <div class="pagelink_left">
       <a href="#2">Back</a>
    </div>
    <div class="pagelink_right">
       <a href="#1">Next</a>
    </div>
    <div class="clear"></div>
</div>

But my experience with jquery is extremely limited so i dont know exactly what i need to change.

I also have jquery which resets the divs so that every time a menu item is selected via <a href="#" class="drop_menu"></a> it always shows first child1 and the correct link to child2:

$(".drop_menu").on('click', function() {
    $(this).parent().find('.child1, a[href="#2"]').show().siblings().hide();
});

My primary question is that i would like to be able to have more than 2 div child’s but don’t know how to update my jquery to reflect that.

1.In child1 i would like ONLY <a href="#1">Replace Child 1 with Child 2</a>

2.In child2 i would like <a href="#2">Replace Child 2 with Child 1</a> AND <a href="#3">Replace Child 2 with Child 3</a>

3.In child3 i would like <a href="#3">Replace Child 3 with Child 2</a> AND <a href="#4">Replace Child 3 with Child 4</a>

4.In child4 i would like <a href="#4">Replace Child 4 with Child 3</a>AND <a href="#5">Replace Child 4 with Child 5</a>.

5.In child5 i would like ONLY <a href="#5">Replace Child 5 with Child 4</a>

So each page has a ‘next’ and ‘back’ link except for the first page which only has a ‘next’ link and the last page which only has a ‘back’ link.

To complicate things further 🙂 some menu items have 2 child div’s, some have 3 child div’s and some have 4 child div’s. In these cases i would like the final page (2, 3 and 4 respectively) to display only 1 link that goes back to the previous page.

Thanks for your help. Pia

  • 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-13T07:54:22+00:00Added an answer on June 13, 2026 at 7:54 am

    You can use the > http://twitter.github.com/bootstrap/javascript.html#carousel for your requirement.

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

Sidebar

Related Questions

I have jquery script which replaces a div when a href=#1 is selected. a
I have the following jquery script: $(function(){ $('#top-menu').on('click', 'a.change-menu', function(e){ e.preventDefault() $(#menu-change-div).load($(this).attr(href)); }); });
I have a jquery script which replaces 1 div with another and replaces 1
I have this jquery script which suppose to hide/show div element base on the
I have a jQuery script, in which I am going to hide the div
I have found and customized this JQuery script, which displays different content when different
I have HTML which includes scripts in following order <script src=../static/js/jquery.js type=text/javascript> <script src=../static/js/bootstrap.js
I have a simple jQuery script which pushes the footer to the bottom of
I have an input text which is this: <div class=editor-label> @Html.LabelFor(model => model.EmployeeId, Employee
I have a div which in jquery's document ready I append - using $(#div

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.