我有以下脚本:
box.copyHeight = function() {
var heights = [],
i, hT;
for (i = 0; i < arguments.length; i++) {
if ($(arguments[i])) {
$(arguments[i]).css('height', '');
if ($(arguments[i])[0] !== undefined) {
heights.unshift($(arguments[i]).height());
}
}
}
hT = heights.sort(function(a, b) {
return a - b;
}).reverse()[0]; //ninja *[1]
for (i = 0; i < arguments.length; i++) {
if ($(arguments[i])) {
$(arguments[i]).css('height', hT + 'px');
}
}
return hT;
};
这一行是调用我的函数
box.copyHeight('article','aside');
这是一个函数,它将高度设置为 <article>
和 <aside>
,永远尊重谁的值(value)最高。
我的问题是它不仅仅适用于 IE 11。
经过一些调试,我得出了一个非常简单的解决方案,即设置 !important 为高度样式。
我的疑问是,如何通过 jquery 做到这一点,更具体地说是在这一行中
$(arguments[i]).css('height','');
我当前的输出是 <article style="700px">
和 <aside style="700px">
, 它必须是
<article style="700px!important">
和 <aside style="700px!important">
.
最佳答案
$(arguments[i]).css('height', hT + 'px !important');
关于javascript - 通过 Jquery 为动态高度为 : Not working in IE11 的标签设置 "!important",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24893599/