jQuery: live change event on IE7

只谈情不闲聊 提交于 2019-12-07 06:55:30

Use jquery .on(). .live() is deprecated.

jQuery(document).on('change', '#lob_drop', function(){
       alert(jQuery('#lob_drop option:selected').val());
   }
);

Demo

What is your JQuery version ?

It works for me on IE7 using JQuery 1.4+ It seems live() wouldn't work with change event in IE in all previous versions.

Use the following:

$('body').on('change', '#lob_drop', function(){
   alert($(this).val());
});

Here's a fiddle with an example: http://jsfiddle.net/7EcGE/24/

My previous suggestion below won't work since .live is deprecated an removed since jQuery 1.9:

jQuery('#lob_drop').live('change',function(){
   alert(jQuery(this).val());
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!