In jQuery, how can I check that a selectbox contains a specific class or not? For example, in the below code snippet, I want to check whether the selectbox with id “customerIds” contains any option with class “C” or “D”.
<select id="customerIds" onchange="doOperation()">
<option value="default"> Start..</option>
<option value="1" class="A"> 1</option>
<option value="2" class="B"> 2</option>
<option value="3" class="C"> 3 </option>
</select>
Use
hasClass()method: http://api.jquery.com/hasClass/For example: