Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/387.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 为什么不是';这个JS不是在ie8中工作吗?_Javascript_Jquery_Internet Explorer 8_Css - Fatal编程技术网

Javascript 为什么不是';这个JS不是在ie8中工作吗?

Javascript 为什么不是';这个JS不是在ie8中工作吗?,javascript,jquery,internet-explorer-8,css,Javascript,Jquery,Internet Explorer 8,Css,我发现这段代码给了我一个对象的最大高度,它在除ie8之外的所有方面都非常有效。有什么我可以改变的,可以让它正常工作吗 function thisHeight(){ return $(this).height(); } $("#new-deals ul.centerSpace").height(function() { var dealNameHeight = Math.max.apply(Math, $(this).find(".deal

我发现这段代码给了我一个对象的最大高度,它在除ie8之外的所有方面都非常有效。有什么我可以改变的,可以让它正常工作吗

    function thisHeight(){
        return $(this).height();
    }

    $("#new-deals ul.centerSpace").height(function() {
        var dealNameHeight = Math.max.apply(Math, $(this).find(".deal-name").map(thisHeight));      
        $(".deal-name").css({height: dealNameHeight});
    });
:如果它回答了您,请删除此问题,并且不接受此答案有答案。(所有贷项均归于标记复制品的人员)


IE8不支持
map()
;作为备用方案,您可以使用下划线来提供
map()
的实现,但浏览器不支持下划线,允许您传递上下文

这让我介绍了第二个问题:您可能对必须传递到
thisHeight
的上下文有问题

var arr = _.map($(this).find(".deal-name"), function(el) { 
   return thisHeight.call(el); //note that el and this are not identical
}, this);
Math.max.apply(Math, arr); //if you use underscore

如果上下文未传递到
此高度
可能引用全局对象,即
窗口

什么不起作用?你有错误吗?