I\'m trying to find a selector in jQuery that select all inputs that are checkboxes and their name contains a specific word like \"top\" or \"Top\". Having trouble b/c its
You were close...
$("input[type='checkbox'][name^='Top']").each()
jsFiddle Demo
you can use start with
selector:
$("input[name^='Top']")
or:
$("input[name^='Top']:checkbox")
I believe you could combine the :checkbox selector and the attribute-contains selector:
$("input:checkbox[name*='top']").each();
Not sure if it needs to be case insensitive, in that case you could have a look at this SO question.
Update:
As bažmegakapa points out in his comment, :checkbox
selector is deprecated according to the documentation. Therefor it is probably better to use:
$("input[type=checkbox][name*='top']").each();