jQuery selector - get <select> element only if <option> is not disabled -
i'm looking jquery selector return <select>
element if <option>
selected not disabled.
html:
<form> <select name="input-select"> <option disabled selected>select option</option> <option value="1">1</option> <option value="2">2</option> </select> </form>
now, if run jquery selector:
$("form select option:selected:not([disabled])")
it either return []
if disabled option select, or either return <option>
selected.
need <select>
element return, know using .parent()
, can't use reason in code.
also
$("form select option:selected:not([disabled]):parent")
doesn't return parent, though :parent
there that?
edit: may guys understand goal:
$.each($("form").find("input[name], textarea[name], select[name] option:selected:not([disabled]):parent"), function(index, value) { console.log(value.name+"="+value.value); });
so, want return every "input" element of form, if valuable me
how using following code determine it:
var selectedoption = $("select option:selected"); if(selectedoption.is(":enabled")) { var parentobject = selectedoption.parent(); console.log(parentobject); }
demo: fiddle
Comments
Post a Comment