Title: Is any checkbox checked with ID matching pattern before and after
Tags: jquery;checkbox
Question: I have a form with checkboxes. The relevant checkboxes have ID attribute starting with pattern stop_ and ending with an underscore and number.
so it might be for example
stop_bla_4
stop_blu_4
but not
stop_bla_5
stop_blz_5
How would I test if none of the checkboxes in a group are checked.
i.e. those that start with stop_ and end with _4 in the above example while ignoring the others.
Comment: @ArunPJohny his IDs ARE unique though.

Here is the accepted answer: This should help you:
// None checked
$('input[type="checkbox"][id^="stop_"][id$="_4"]:checked').length == 0
jQuery references
Selector "attribute starts with": http://api.jquery.com/attribute-starts-with-selector/
Selector "attribute ends with": http://api.jquery.com/attribute-ends-with-selector/
Comment for this answer: I used `length` because you asked about the unchecked ones (number of checked == 0), but based on the selector you can achieve any situation.
Comment for this answer: how does this work if some are unchecked and some are checked? why does it show only if all or unchecked?


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 1, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2013:00:11/04/13', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<jquery><checkbox>', 'Title': 'Is any checkbox checked with ID matching pattern before and after', 'ViewCount': 343, 'id': 19764266, 'user_AboutMe': None, 'user_AccountId': 1022838.0, 'user_DisplayName': 'Ray S.', 'user_Reputation': 1152.0, 'user_Views': 83.0, 'user_id': 1032755.0}}