Uday kumar das Uday kumar das - 1 year ago 66
jQuery Question

find dropdown by attribute disabled false

I have same dropdown many times in my file like:

<select style="width:40%;" name="article[subsection_id]" id="article_subsection_id" class="article_subsection_cls" disabled="disabled"><option value=""></option>

I want to find dropdown by class
or id
and attribute

Answer Source

Use attribute equals selector with :not() pseudo selector


If disabled property updated dynamically in that case use filter() method

$('select.article_subsection_cls,select#article_subsection_id').filter(function(){ return !this.disabled; })

UPDATE : In case there is only one element use id selector


Or you can use :enabled selector

Although their resulting selections are usually the same, :enabled selector is subtly different from :not([disabled]); :enabled selects elements that have their boolean disabled property strictly equal to false, while :not([disabled]) selects elements that do not have a disabled attribute set (regardless of its value).