jQuery直播,改变不在IE6,IE7中工作

16 javascript jquery internet-explorer

下面的代码在FF中按预期工作,但在IE中没有...

$(document).ready(function() {

    $('div.facet_dropdown select').live('change', function() {
        var changed_facet = $(this).attr('id');
        var facets = $('select', $(this).closest('form'));
        var args = window.location.href.split('?')[0] + '?ajax=1';
        var clear = false;
        for(var i = 0; i < facets.length; i++) {
            var ob = $(facets[i]);
            var val = ob.val();
            if(clear) {
                val = '';
            }
            args += '&' + ob.attr('id') + '=' + val;
            if(ob.attr('id') == changed_facet) {
                clear = true;
            }
        }

        $.getJSON(args, function(json) {
            for(widget_id in json) {
                var sel = '#field-' + widget_id + ' div.widget';
                $(sel).html(json[widget_id]);
            }
        });

    });

});
Run Code Online (Sandbox Code Playgroud)

小智 24

$.live()不支持该change事件:

目前不支持:模糊,焦点,鼠标中心,鼠标离开,更改,提交 http://docs.jquery.com/Events/live

尝试使用livequery代替?

  • 完善!非常感谢!livequery诀窍! (2认同)