How to get the value of & lt; p: selectOneMenu & gt; in jquery?


Hi am trying to get the value of p:selectOneMenu from jquery , but i dint got as yet. am using JSF and primefaces as my UI component.

    <p:selectOneMenu style="width:150px" id="skill"
                value="#{loginBean.skill}" required="true" immediate="true"
                requiredMessage="Select your skill" label="skill" styleClass="someClassName">
                <f:selectItem itemLabel="Select" itemValue=""></f:selectItem>
                <f:selectItem itemLabel="Other" itemValue="Other"></f:selectItem>
                <f:selectItems value="#{loginBean.skillList}" var="item"
                    itemLabel="#{item}" itemValue="#{item}"></f:selectItems>

In Html

<select id="skill_input" name="skill_input">
<option value="">Select</option>
<option value="Other">Other</option>
<option value="Tailoring">Tailoring</option>
<option value="Swimming">Swimming</option>
<option value="Roaming">Roaming</option>

thats my select one menu, my js is..

  var $element = $('.someClassName');


in the alert box i got as, [object Object], but not the selected value.

then i tried this,

   var $element = $('.someClassName').val();


but now i got an empty alert box.

then i tried this

 var $element = $("select[name='skill_input']:selected").val();


my alert box says undefined

What else i should do to get the selected value in that alert box..??

Try this

var $element = $("select[name='skill_input'] option:selected").val();