'How to Iterate through a select option list using a class Id

As you can see, I have a td with a className templateCell . I need to iterate through the td and find the option having text as (inactive) and mark its attribute as disabled to true. This is what Expect. Please click the link. http://jsfiddle.net/atqLwm5u/4/

Anything marked as (inactive). I want to disable that item from my mulitiselect dropdownlist .

This is what i have tried. This is what i get. It does not change anything in my selected item. ANY idea How to Prevent Default after a tag call ?? enter image description here

This is what i have thought

<select id="dp1" class="text_select" name="field_0_1" >
<option value="Version0" > Version0 </option>
<option value="Version1(inactive)"> Version1(inactive) </option>
<option value="Version2(inactive)">Version2(inactive) </option>
<option value="Version3">PVersion3 </option>  
</select>
//Jquery 
$(".text_select option[value*='inactive']").attr('disabled','true');

I think i need to iterate and use this above example. What you are seeing is a Kendo UI multiselect Select2 dropdownlist HTML tags. Thank you in advance



Solution 1:[1]

Given you just want to look at the innerText of the options, you can use the following:

$('.templateCell select option:contains("inactive")').attr('disabled','true');

This will select all option elements that contain the text "inactive" that are within the select that's located in the td.templateCell element and set the disabled property to true, given that the option innerText contains "inactive".

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dharman