I need to programmatically change the option that is selected within a select.
I have code registered to run when this occurs, whether the selection
is initiated by the user or programmatically.
Why doesn't this approach work?

$(document).ready(function () {
  $("select#foo").change(function () {
    alert("Now selected: " + $("select#foo > option:selected").text());
  }
}

var select = $("select#foo");
select.find("option:first").select();
select.change();

The alert is only displayed when the user changes the selection, not
when the code above changes it.

-- 
R. Mark Volkmann
Object Computing, Inc.

Reply via email to