I need to disable options with value '- Sold Out -' in a list of dynamic drop down menus. How can I do this easily with jQuery? Below is the HTML
).prop('disabled',true);
CopyDemoAccording to edit$('#previous_select').on('change', function() {
// after creating the option// try following
$("select option[value*='Sold Out']").prop('disabled',true);
});
CopySolution 2:
Working demohttp://jsfiddle.net/BYkVW/orhttp://jsfiddle.net/BYkVW/1/Hope it helps the needs :)code$("#field_0_1 option[value='- Sold Out -']").attr('disabled','disabled');
Copyor$("#field_0_1 option[value='- Sold Out -']").prop('disabled','disabled');
Copyworking imageSolution 3:
functionlockDownDropDownList(ddlName) {
ddlName = "#" + ddlName;
var chosenValue = $(ddlName).val();
var downDownListItems = $(ddlName).children('option').map(function (i, e) {
return e.value || e.innerText;
}).get();
downDownListItems.forEach(function (item) {
if (item != chosenValue)
{
$("select option[value*='" + item + "']").prop('disabled', true);
}
});
}
CopySolution 4:
Here i have done solution for above query. demo link as below:Demo:http://codebins.com/bin/4ldqp92HTML:<selectid="field_0_1"class="text_select"name="field_0_1"onChange=""><optionvalue="">
- Preferred Time -
</option><optionvalue="- Sold Out -">
- Sold Out -
</option><optionvalue="2:30 - 4:00pm">
2:30 - 4:00pm
</option></select><selectid="field_0_2"class="text_select"name="field_0_2"onChange=""><optionvalue="">
- Preferred Time -
</option><optionvalue="- Sold Out -">
- Sold Out -
</option><optionvalue="2:30 - 4:00pm">
2:30 - 4:00pm
</option></select><selectid="field_0_3"class="text_select"name="field_0_3"onChange=""><optionvalue="">
- Preferred Time -
</option><optionvalue="- Sold Out -">
- Sold Out -
</option><optionvalue="2:30 - 4:00pm">
2:30 - 4:00pm
</option></select>CopyJQuery:$(function() {
$("select").click(function() {
$(this).find("option[value*='Sold Out']").prop("disabled", true);
});
});
CopyDemo:http://codebins.com/bin/4ldqp92Solution 5:
$("#ddlList option[value='jquery']").attr("disabled","disabled");
Copy
Share
Post a Comment
for "Disable Drop Down Option Using Jquery"
Top Question
Firefox, Chrome, Safari Have Grey Background For Mp4 Html5 Video
Any video (that I can make) with a white background becomes…
Red Border Still Appears On Inputs After Resetting An HTML 5 Form Firefox
I have an HTML 5 form! Great, I'm excited! I decide to …
Svg Animation And Firefox
I'm struggle with SVG animation drawing, which is work …
Form To Iframe Submission - How Do You Reset The Form After File Upload?
I have a form that submits the results to an iframe. The su…
How To Hide/show Tabs Using Jquery
I have four tabs.On loading only the first tab is opened an…
How To Save Html5 Geolocation Data To Python Django Admin?
Is it possible to save the javascript html5 geolocation lat…
How To Limit The Html Table Records In Each Page
I am populating a table in my jsp which has more than 20 re…
How To Display A Python String As Html In Jupyter Notebook
In IPython notebook, I used to be able to display a python …
How To Add Placeholder Field?
I've been trying to add placeholder in input type='…
Bounce Animation On A Scaled Object
What is the best way to have an object scale and then perfo…