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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:53:02+00:00 2026-06-08T00:53:02+00:00

I have this mark-up: <div> TEXT <a class=toggle-action> TOGGLE </a></div> <dl class=collapsed> … </dl>

  • 0

I have this mark-up:

<div> TEXT <a class="toggle-action"> TOGGLE </a></div>
<dl class="collapsed">
  ...

</dl>
<dl class="collapsed">
  ...
</dl>

When I click on the toggle link, all the <dl> elements below should toggle their class from expanded to collapsed and back. But only the first level of DLs, because some of them might have DD elements with other DLs…

How can I do this with javascript?

I know how to do it with jQuery, but I’d like to avoid it because it adds too much load just for this thing.

Currently I have this:

document.addEventListener('click', function(e){

  // my link
  if(e.target.className.indexOf('toggle-action') !== -1){
     // here how to select DLs?
  }

});

🙂

  • 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-08T00:53:04+00:00Added an answer on June 8, 2026 at 12:53 am

    refer the following link:-
    http://www.daniweb.com/web-development/javascript-dhtml-ajax/code/217121/changing-the-classname

    Its trying to do similar stuff like you but in js

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

Sidebar

Related Questions

I have several div elements like this: <div class=newsContainer> <div class=deleteBoxIcon> <img alt=Delete src=close_mark.png>
I have the following mark-up: <fieldset> <div> <label class=editor-label>Question 1?</label> <input type=text class=editor-field />
I have @hash that looks like this: [1, {:clid=>1, :nvz=>4, :tip=>IP, :name=>Mark, :record=>some text}]
This is the code HTML <div id=footmain> <div id=col1 class=mark></div> <div id=col2 class=mark></div> <div
Problem I have the following mark-up: <div id=progress-bar> <div id=step-1 class=active><p>1. Select Room</p></div> <div
In Hotspot, when System.gc() is invoked, I can have this use the Concurrent-Mark-Sweep collector
I have created an array in php that prints this Array ( [mark] =>
I have this form: <%= form_tag posts_path, :method => :get, :class => search_nav do
I have text files with tables like this: Investment advisory and related fees receivable
I have the following mark-up: $(document).ready(function () { $('.lalala').bind('blur', function (e) { CheckFirstInput($(this)); });

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.