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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:22:54+00:00 2026-06-15T19:22:54+00:00

I want to make a div, or to be more precise, an aside element

  • 0

I want to make a div, or to be more precise, an “aside” element which has an id or class to appear when another element that has the same class is clicked… I know that there is the standard class selector but I want there to be more than one “aside” element with different id’s or classes and I want that one to be opened that has the same class or id as the clicked element…

So, I don’t want to write the this code for every single div:

    $(window).load(function(){
      $('nav ul li#someid').click(function () {
      $('aside#someid').toggleClass('opened');
      });
    });

I want code like this. Is there a way to change the someid from the example to something that detects what id the clicked element has and use it as the “aside” selector?

  • 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-15T19:22:54+00:00Added an answer on June 15, 2026 at 7:22 pm

    First off, you may want to know that you can use this to access the object that was clicked on. That means you can get this.id or this.className to get the id or class of the object that was clicked on. Now, exactly what you do with that info depends upon how your HTML is structured so we’d need to see that to provide more specifics.

    You cannot have multiple objects in the same page with the same ID. You simply cannot do that (selectors will not work properly when you do that) so your desired scheme will not work. You could use classes instead and toggle the other item with the same class. This would work for one particular li.

    $(document).ready(function(){
        $('nav ul li.foo').click(function () {
            $('aside.foo').toggleClass('opened');
        });
     });
    

    Or, depending upon your HTML (if you only have one class on the li tag), you could do a more general version like this:

    $(document).ready(function(){
        $('nav ul li').click(function () {
            $('aside.' + this.className).toggleClass('opened');
        });
    });
    

    If you show us your actual HTML, we could provide the best options.

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

Sidebar

Related Questions

I want to make a div that is centered (horizontally and vertically). It should
I want to make a DIV background (which doesn't have a background color) flash
I want to make a viewport type that basically wraps a <div> tag with
I want to make a big selection box , <ul> <li> <div class=sbox> <img
I have an element, like this: <div id=navleft> </div> I want to make this
I want make a bash script which returns the position of an element from
I have a div id overlay that I want to make visible when the
I want to make several (more than 12) slideshows on one page, which will
I have a box that has the div class box_1 assigned to it. Now
I have DOM element and I want to make a duplicate of it which

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.