[jQuery] jQuery Newbie - Getting value of a Select Option
I'm a complete newbie to jQuery trying to perform a relatively simple
task, but can't figure it out.
Based of the value of a select option, I want to hide/show a div. How
do I get the value of the select option? Here's what I have below.
Thanks for your help!
$(document).ready(function(){
var hearOther = $("#hear_other");
hearOther.hide();
$("#hear").change(function(){
if( $("#hear_other option[value='O']")){
alert('show hearOther');
}else{
alert('hide hearOther');
}
});
});
<select id="hear">
<option value="T">Television</option>
<option value="R">Radio</option>
<option value="O">Other</option>
</select>
<div id="hear_other">Please describe “Other”</div>