I need to disable values of options in select that are less than some number, which I do not know beforehand (it is set in another form element). I need something like code below, but with variable value of "variableInteger":
select.children().filter(function() {
return $(this).attr("value") > variableInteger;
}).each(function () {$(this).attr('disabled', 'disabled')});
Is there some clever way to do it?
PS. variableInteger value is from another form element, which name is also known only at runtime.
No need for the .each
, also make use of prop
and this.value
(no need for $(this).attr("value");
)
select.children("option").filter(function() {
return this.value > variableInteger;
}).prop("disabled", true);
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments