对象不支持IE中的此属性或方法

时间:2012-02-22 01:47:25

标签: jquery object internet-explorer-8

我再次需要帮助

以下代码适用于除IE,IE8之外的所有浏览器。问题领域是:

$(function () {
    $('area').live('mouseover mouseout', function (event) {
        mapObject.qmap($(this), event);
    });
});
});

完整的代码是:

 $(document).ready(function () {
     var mapObject = {
         qmap: function (area, event) {
             var ida = area.attr('name');
             if (event.type == 'mouseover') {
                 $('.' + ida).show();
                 $('#' + ida).siblings().each(function () {
                     if ($(this).is(':visible')) {
                         $(this).hide();
                     }
                 });
                 $('#' + ida).show();
             }
             else {
                 $('.' + ida).hide();
                 $('#' + ida).hide();
                 $('#map-0').hide();
             }
         }
     };
     $(function () {
         $('area').live('mouseover mouseout', function (event) {
             mapObject.qmap($(this), event);
         });
     });
 });

我试图从其他类似的帖子中解决这个问题但没有成功。

感谢任何帮助。

1 个答案:

答案 0 :(得分:1)

为什么不是这样的简单版本:

$(function() {
    function mapObject(e) {
        var area = $(this);
        var ida = area.attr('name');
        if (e.type == 'mouseover') {
            $('.' + ida).show();
            $('#' + ida).siblings().each(function() {
                if ($(this).is(':visible')) {
                    $(this).hide();
                }
            });
            $('#' + ida).show();
        } else {
            $('.' + ida).hide();
            $('#' + ida).hide();
            $('#map-0').hide();
        }
    }
    $(document).on('mouseover mouseout', 'area', mapObject);
});
相关问题