FrenkyB FrenkyB - 6 days ago 5
Javascript Question

HTML search by two properties

I would like to be able to search for checkboxes which are not disabled (attribute

disable
is not set to
"disabled"
:

My function is below. I am able to find all checkboxes, but I don't know how to search for not-disabled checkboxes:

MarkAllColumns = function () {

if (MarkAll === true) {
$("#tblArticlesSearch input[type=checkbox]").prop('checked', true);
}
else {
$("#tblArticlesSearch input[type=checkbox]").prop('checked', false);
}


}

I want to set attribute
checked
to true only on not-disabled checkboxes.

Answer

You can either use :enabled selector or combine :not with :disabled selector

$("#tblArticlesSearch input[type=checkbox]:enabled")

or

$("#tblArticlesSearch input[type=checkbox]:not(:disabled)")