How to select a value from option using click function

How to select a value from option using click function
0

#1
> <select>
> <option>test</option>
> <option value="12">test</option>
> </select>

Can select that 12 value from a jquery click function any idea?


#2

You can get attributes in jQuery using the attribute function:

http://api.jquery.com/attr/

In your situation you would use the following code:

$(“option”).attr(“value”);

However note that you have two options without any id. jQuery will say the value is undefined because it will be looking at the first where there is no value.