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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:53:15+00:00 2026-05-13T10:53:15+00:00

I am looking for a way in which I can grab an element id

  • 0

I am looking for a way in which I can grab an element id from my page like this:

<div id="events"> 
    <div id="event_1765" class="type_automotive start_125x125 color_Black"> 
        <h3>Leftlane News</h3> 
    </div> 
</div>

I would like to get the id=”events” but I need it in this script where the events is:

    $("input.type_check").click(function() {
        if($(this).is(':checked')) {
            $("#events div."+$(this).attr('id')).removeClass('type_hidden');
            $("#events div").not(".type_hidden, .start_hidden, .color_hidden").css("display","block");
        } else {
            $("#events div."+$(this).attr('id')).addClass('type_hidden');
            $("#events div."+$(this).attr('id')).css("display","none");
        }
    });

so, in other words I would like to replace the ‘events’ in the jquery script with a code that dynamically gets the id element on the html page.

  • 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-13T10:53:16+00:00Added an answer on May 13, 2026 at 10:53 am

    Firstly, don’t use css() to hide them when you’re also putting a class on. You could just as easily do this in your CSS:

    div.type_hidden { display: none; }
    

    or just not use that at all.

    $("input.type_check").click(function() {
      $("div." + this.id).toggle($(this).is(":checked"));
    });
    

    This:

    • gets the ID attribute of checkbox that’s clicked (eg “type_automotive”);
    • uses that in a class selector to hide/show divs with that class; and
    • checks on the checkbox status to see if it needs to hide or show them.

    There’s no need for a “type_hidden” class or css("display", "none") (which you shouldn’t do in preference to using jQuery effects anyway).

    Note: this all assumes (from your site):

    <input name="type[]" type="checkbox" id="type_automotive"
      value="automotive" class="type_check" checked="checked" /> 
    

    and

    <div id="events"> 
      <div id="event_1768" class="type_automotive start_300x250 color_Black"> 
        <h3>Autoblog</h3> 
      </div> 
    </div> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for a way to delete a file which is locked by another
I'm looking for way to PHP to detect if a script was run from
I'm looking for any way that I can improve the selector performance of a
I'm looking for a way to stream a PDF file from my server to
I have an ALPHA application which allows you grab an obfuscated font from and
I have a GWT application which I would like to run from within a
Just looking for the best practise way of doing this. I have a table
I am using the jquery-ui-dialog plugin I am looking for way to refresh the
I looking for a way, specifically in PHP that I will be guaranteed to
I looking for a way to programmatically start a VOIP call using the SIP

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.