0

I am using a simple select element. On selecting a option in the select menu, I want to use jQuery's post method to update the div.

<select class="article">
    <option value="title1">title1</option>
    <option value="title2">title2</option>
    <option value="title3">title3</option>
</select>

I want to bind the change event to the select element.

$(document).ready(function() {
    $(".article").change(function() {
        var src = $(this).val();
        alert(src);
    });
});

This does not work. I don't see the alert box on changing the select box.

I appreciate any help.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Josh Randall
  • 1,284
  • 4
  • 18
  • 31

3 Answers3

0

It does work fine

Working demo

ShankarSangoli
  • 69,612
  • 13
  • 93
  • 124
0

This should work fine, have you included jQuery files. Please check that jQuery is included properly.

$(document).ready(function() {
    alert('hello');
});

This should give an alert, in case this does not, then jQuery is not working properly.

pimvdb
  • 151,816
  • 78
  • 307
  • 352
sesmic
  • 928
  • 4
  • 15
  • 32
-1
$('select.foo option:selected').val();    // get the value from a dropdown select

More about the subject;

http://api.jquery.com/val/

http://api.jquery.com/selected-selector/

jQuery - setting the selected value of a select control via its text description

Community
  • 1
  • 1
Stefan
  • 5,644
  • 4
  • 24
  • 31