jQuery:IE7上的实时更改事件 [英] jQuery: live change event on IE7

查看:67
本文介绍了jQuery:IE7上的实时更改事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在下拉选择中捕获更改事件。此下拉字段是使用AJAX创建的,因此事件捕获需要使用live或bind来完成。
这里我添加了我目前正在使用的代码。这是火狐。在IE7上它不起作用。任何人都可以告诉我一种方法来捕获IE7上的下拉选择直播事件

I have capture change event on drop down select. This drop down field is created using AJAX so event capture need to be done with live or bind. Here I add the code which I'm using currently. This is working on fire fox. On IE7 its not working. Can anyone tell me a way to capture live event of drop down select on IE7



    <select id="lob_drop" name="opt" class="select">
       <option value="1">option 1</option>
       <option value="2">option 2</option>
       <option value="3">option 3</option>
    </select>

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


推荐答案

使用jquery .on() .live() 已弃用

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

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

演示

这篇关于jQuery:IE7上的实时更改事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆