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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:57:56+00:00 2026-06-13T10:57:56+00:00

How do remove a div by clicking on it, but hide or display any

  • 0

How do remove a div by clicking on it, but hide or display any of the divs with name or age in the ID.

One checkbox should toggle any divs with “name” at the beginning of the ID, and another checkbox should toggle any divs with “age”at the beginning of the ID

<div id="container">
  <div id="name-254"></div>
  <div id="age-645"></div>
  <div id="name-142"></div>
  <div id="name-341"></div>
  <div id="age-341"></div>
  <div id="name-341"></div>
</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-06-13T10:57:57+00:00Added an answer on June 13, 2026 at 10:57 am

    In order to make the div elements self-destruct when you click on them you could do the following:

    // Inside the #container, when somebody clicks a div
    $("#container").on("click", "div", function(){
       // Remove that div
       $(this).remove(); 
    });​​​​​
    

    As for checkboxes that toggle the visibility of each set:

    // When somebody clicks on a checkbox
    $(":checkbox").on("click", function(){
        // Reference for the checkbox, its name, and checked property (true|false)
        var chbx = $(this),
            name = chbx.attr("name"), 
            show = chbx.prop("checked");
    
        // Find elements whose id begins with the checkbox name
        // and set their toggle to true or false
        $("[id^=" + name + "]").toggle( show );
    });
    

    See it in action here: http://jsfiddle.net/6GBpW/3/

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

Sidebar

Related Questions

I would like to remove one div element, but without its children. For example,
removeClass doesn't remove the class selected from div.upvote in the js below, but addClass()
I am using jQuery's .remove() to get rid of divs of content, but I
I want to add and remove div element using jquery and adding of div
I need to remove break from a specific div , i know how to
I'm trying to remove contents of particular div which are basically list items and
How to remove a class that has been appended to a div id? Earlier
I have the following function to remove a DOM element div, $('#emDiv').on(click, ':button[data-emp-del=true]', function
I want to add row with remove button through javascript in html div formate.
I have a div with ID 'adpictureholder', to which I dynamically add (or remove)

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.