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

  • Home
  • SEARCH
  • 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 7053039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:27:22+00:00 2026-05-28T03:27:22+00:00

I am using jQuery for the first time (my js knowledge is poor at

  • 0

I am using jQuery for the first time (my js knowledge is poor at best) and attempting to create a Section filter (hides/shows divs depending on class) that is based around checkbox options.

To start with I was wanting to retrieve the class of each checkbox that was checked so I have something like this (the div.text is just to test the output). Each checkbox class corresponds to the class of the div (all div’s have multiple classes that match various checkboxes)

<ul>
    <li>Size</li>
    <li><input type="checkbox" class="half" />&frac12;"</li>
    <li><input type="checkbox" class="quart" />&frac34;"</li>
</ul>

<script>
    function Checked() {
        var n = $("input:checked").attr("class");
        $("div.text").text(n);
    }

    Checked();
    $(":checkbox").click(Checked);
</script>

This succesfully returns the first checked checkbox class, I toyed around with each() but don’t quite understand how to implement it, can someone point me in the right direction please?

Ultimately I’m looking for each checked checkbox class to be in an array that I can then call upon to make the corresponding divs the only visible items, but I’m happy to take this a step at a time. I’m sure this is likely to be an easier way to achieve the desired result so am also open to suggestions. Thanks in advance

  • 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-28T03:27:23+00:00Added an answer on May 28, 2026 at 3:27 am

    Try this

    function Checked() {
      var classes = [];
      $("input:checked").each(function(){
           classes.push($(this).attr('class'));
      });
      $("div.text").text(classes.join(','));
    }
    Checked();
    $(":checkbox").click(Checked);
    

    Inside the each loop this points to each of the checked checkbox element. Using this we get the class and then push it inside an array just to store all the classes and then display them using join method of the array.

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

Sidebar

Related Questions

I'm using jQuery UI for the first time, and I'm going to create a
I'm working on a site and using JQuery for essentially the first time. I've
This is my first time using JQuery in any of my projects. I have
this is my first time using jquery, and i dont think it seems to
I am using jquery layout for the first time. I have it working using
I'm using Sencha for the first time. Previously, I've been using jquery. What is
I am using jQuery Masonry script. When loading the page first time everything is
First time using jQuery parent and got confused, here's my html: <div id=friends_inveni class=friends_rec
I am using jQuery-ui slider for the first time and am confused by a
I am using jQuery for the first time to add a class to an

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.