dynamic - Binding to the change event in dynamically created dropdown list using jQuery -
i creating number of dropdown lists dynamically using jquery. able trigger event when selected dropdown list item changes. browsing on here , elsewhere see it's not possible bind change event of dropdown lists using live() wondering alternatives? know it's possible bind click event since occurs before dropdown list selection can change it's no use me tracking if selected item has changed.
this relevant part of code. alert triggers when of dropdown lists clicked on of course prefer if alert triggered when selected item changed.
$(document).ready(function() { // stuff omitted. addeventhandlers(); } function addeventhandlers() { // stuff omitted. $('#divreview select').live("click", function(){ alert('this change event occur instead.'); }); }
use change
event instead of click
, this:
$('#divreview select').live("change", function(){
there bug in ie before jquery 1.4.2 release. before then, change
didn't bubble correctly in ie (which .live()
relies on), fixed in 1.4.2, if using version or higher, should work.
Comments
Post a Comment