Given a jQuery element like so:
$(selectElt)
How do I access the first option? Note I am not interested in a selector given the select menu's id, e.g.
$('#selectmenu1 option:first')
What I am given is the select element itself, $(selectElt)
, from which I need to select the first option element.
Just do:
$(selectElt).children("option:first");
or
$(selectElt).children("option:eq(0)");
or
$(selectElt).children("option:nth-child(1)");
or contextually:
$("option:first", selectElt)