jQuery select box with disable-able options -
i'm looking jquery/javascript select box html forms. specific requirement in case need able disable options in control's menu. i'd know if has found plugin allows me this, preferably using
$("#selectcontrol").change(function() { $(this).find(":selected").attr("disabled", "disabled"); });
of course, attr()
function won't work on generated element, there jquery plugin has wrapper functionality?
edit
to make myself clearer, i'll differently: have html structure looks nicely styled select box, hidden actual <select>
control behind it. it's possible disable <option>
in <select>
, not in jquery plugins styling select boxes. i'm asking if there plugin out there will allow me disable options in prettified <select>
element.
thanks,
james
i'm not sure i'm tracking on question, code snippet below operates on dropdown, hide options:
//show them $('#<%= ddlrank.clientid %> span').each( function () { var opt = $(this).find("option").show(); $(this).replacewith(opt); } ); //hide unrelated var selectionlost = false; $('#<%= ddlrank.clientid %> option').each( function () { if ($.inarray($(this).val(), related) == -1) { if ($(this).attr("selected")) { $(this).removeattr("selected"); selectionlost = true; } $(this).wrap("<span>").hide(); } } );
the secret sauce (to hide them, in conjunction "show all" code) is:
$(this).wrap("<span>").hide();
Comments
Post a Comment