Javascript 为什么不是';这个JS不是在ie8中工作吗?
我发现这段代码给了我一个对象的最大高度,它在除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
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
如果上下文未传递到
此高度
,此
可能引用全局对象,即窗口
什么不起作用?你有错误吗?