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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:34:13+00:00 2026-05-23T00:34:13+00:00

I have a list of input elements and using one selector I want to

  • 0

I have a list of input elements and using one selector I want to find those that

  1. are checkboxes
  2. have the value attribute set

Can I do that?

I tried:

  • $(items).find("input:checkbox[value]")
  • $(items).find("input[value]:checkbox")

But both ignore the [value] and only test for input:checkbox.

Sure, I can use two selectors, but just one would be nicer.


My essential use case is this.

Basically, I want to take some action on a checkbox based on whether other checkboxes are unchecked or not. In this example the “parent” checkbox is still checked because the jQuery selector "input[value]:checkbox" in function getChildrenCheckboxes matches the “No Child” checkbox as well as the other checkboxes.

  • 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-23T00:34:14+00:00Added an answer on May 23, 2026 at 12:34 am

    Firstly, if people take the time to provide you with answers, you could at least take the effort in accepting those answers.

    Secondly, regarding your question you can either use filter() or check whether value is empty:

    $('input[value!=""]:checkbox').addClass('selected');
    

    http://jsfiddle.net/niklasvh/pEK3c/

    or

    $('input:checkbox').filter(function(){
     return this.value.length;   
    }).addClass('selected');
    

    example: http://jsfiddle.net/niklasvh/duAB8/

    edit

    Regarding the question why not just use $('input[value]') to check the presence of a value, firstly it depends whether you want to know whether its empty, or not there at all, and secondly, and perhaps most importantly, do you want it to work consistently over different browsers?

    The following markup:

    <input type="checkbox" value="2" />
    <input type="checkbox" value="" />
    <input type="checkbox"  />
    <input type="checkbox" value="23" title="a" />
    

    With the following selector:

    $('input:[value]:checkbox').prop('checked',true);
    

    Will give the following results:

    Chrome 11, X - - X
    FF4,       X - X X
    IE 8,      X - X X
    

    So are you interested in knowing whether the attribute is defined, or whether its empty? If the first one, you can expect differentiating results for that selector. Where as the 2 first examples both give consistent results for X - - X.

    It’d be quite a different story if you’d be looking for the [title] attribute…

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

Sidebar

Related Questions

I want to build a query that finds elements that have the autofocus-attribute and
I have a list of file input boxes and I want to know if
I have an input field that uses Autocomplete to show a list of possible
I have a form containing a list of input fields that the user populates
I am using List<T> array to store all ID's that I have read from
I have list of input area in the form with id like contact1_title, contact2_title,
I have a list of input type radio buttons in formview (edit mode) and
I have this code for splitting input list into its halves. It seems to
I have a basic unordered list with an input field/form below it. I would
I have a Scheme assignment in which a user is to input a list

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.