jquery - How to check if dropdown is disabled? -
jquery - How to check if dropdown is disabled? -
using jquery how check if read only?
this trying..
$("#item").keydown(function (event) { //alert(event.keycode); if (event.keycode == 13) { $("#ok").click(); if ($('#droplength').prop("disabled") == false) { $("#droplength").focus(); return; } if ($('#dropunit').prop("disabled") == false) { $("#dropunit").focus(); return; } $("#qty").focus(); homecoming ; } }); the dropdowns set readonly using jquery also:
if ($('#droplength').find('option').length <= 1) { $('#droplength').attr("disabled", "disabled"); } if ($('#dropunit').find('option').length <= 1) { $('#dropunit').attr("disabled", "disabled"); }
the legacy solution, before 1.6, utilize .attr , handle returned value bool. main problem returned type of .attr has changed string, , hence comparing == true broken (see http://jsfiddle.net/2vene/1/ (and switch jquery-version)).
with 1.6 .prop introduced, returns bool.
nevertheless, suggest utilize .is(), returned type intrinsically bool, like:
$('#dropunit').is(':disabled'); $('#dropunit').is(':enabled'); furthermore .is() much more natural (in terms of "natural language") , adds more conditions simple attribute-comparison (eg: .is(':last'), .is(':visible'), ... please see documentation on selectors).
jquery
Comments
Post a Comment