Check value select option list

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:

  var selectVal = $(‘select’).val();

            if( $selectVal=="maybe"){

Unfortunally this doesn't work. Anybody has an idea what i'm doing wrong or how to do it right?


  var selectVal = $(this).val();

  if( selectVal=="maybe"){


$selectVal is different from selectVal. And smart quotes are a no-no in jQuery selectors.

You also need to hide the paragraph onload. CSS display: none can do this best.

Incidentally, you can pass a Boolean to the .toggle() method to shorten up your code:

$('select').change(function() {
    var selectVal = $(this).val();

Need Your Help

Change the escape sequence generated

linux keyboard terminal centos terminfo

This question is a general version of my previous question: Change the escape sequence generated by xterm for key combinations.