I´ve got a wordpress plugin that generates an option list. The generated code is like this:
<select name="question">
<option value="yes">Yes</option>
<option value="no">No</option>
<option value="maybe">Maybe</option></select>
<p id="text">some text</p>
Underneath is a paragraph i like to show if the option maybe is selected. If Yes or No is selected this should be hidden.
The Jquery script i came up with (after lot’s of googling, copying and pasting) is this:
$('select').change(function(){
var selectVal = $(‘select’).val();
if( $selectVal=="maybe"){
$('#text').show();}
else{
$('#text').hide();}
});
Unfortunally this doesn’t work. Anybody has an idea what i’m doing wrong or how to do it right?
jsfiddle: http://jsfiddle.net/ufomammut66/xqCKD/