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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:32:32+00:00 2026-05-25T01:32:32+00:00

I have 3 elemets that are hidden from the beginning, there are also 3

  • 0

I have 3 elemets that are hidden from the beginning, there are also 3 links to show them with slideToggle. I’m looking for some solution to make my code simplier and to be more smart. I also have this problem, when a element is visible and I click on another link, I would like the visible link to toggle back before it toggle the new. As my code is now, it only toggles back when I click on the same link, but then the class that add bold font to indicate a selected link still gets bold. Hmmmm, could this be done in a better way? Precaite some help! Thanks!

$(document).ready(function(){

$("#info").click(function() {
$("#aktuellt").removeClass("startsida_extra_selected");
$("#kontakt").removeClass("startsida_extra_selected");
$("#info").addClass("startsida_extra_selected");
$("#startbild_info").slideToggle("fast");
});

$("#aktuellt").click(function() {
$("#info").removeClass("startsida_extra_selected");
$("#kontakt").removeClass("startsida_extra_selected");
$("#aktuellt").addClass("startsida_extra_selected");
$("#startbild_aktuellt").slideToggle("fast");
});

$("#kontakt").click(function() {
$("#info").removeClass("startsida_extra_selected");
$("#aktuellt").removeClass("startsida_extra_selected");
$("#kontakt").addClass("startsida_extra_selected");
$("#startbild_kontakt").slideToggle("fast");
});

});

The HTML code for the jQuery:

<div id="startbild_info">
<p>info</p>
</div>

<div id="startbild_aktuellt">
<p>aktuellt</p>
</div>

<div id="startbild_kontakt">
<p>kontakt</p>
</div>
  • 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-25T01:32:32+00:00Added an answer on May 25, 2026 at 1:32 am
    $(document).ready(function(){
    
      var elements = $("#info, #aktuellt, #kontakt");
    
      elements.click(function(event) {
        event.preventDefault();
    
        var element = $(this);    
        var element_id = element.attr("id");
        var bild_element = $("#startbild_"+element_id);
    
        elements.removeClass("startsida_extra_selected");        
    
        bild_element.slideToggle("fast",  function(){
            // After the toggle is finished, check if bild_element has opened or closed
            // If bild_element has opened the class is added to element.
            if(bild_element.is(":visible") === true)
            {               
               element.addClass("startsida_extra_selected");  
            }
        });
      });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some link elements which are dynamically added and hidden from the page.
I have hidden Divs with .display-link classes that are two levels up from an
How to select next n hidden elements that have class foo using jQuery?
I have code that loads a bunch of images into hidden img elements and
I am trying to show only elements that have the title attribute passed to
I have posts that are echoed out of my mysql database. If there is
I have a script (JS) running that will be making some different divs either
I have two span elements that I would like to stay on the same
I have two div elements that are twins (i.e. their dimensions and contents are
I have a bunch of input elements that have a particular substring in their

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.