Javascript 将IE黑客与JQuery css()结合起来?
我需要调整IE7的元素高度。通常我会在我的外部样式表中使用hackJavascript 将IE黑客与JQuery css()结合起来?,javascript,jquery,css,internet-explorer,cross-browser,Javascript,Jquery,Css,Internet Explorer,Cross Browser,我需要调整IE7的元素高度。通常我会在我的外部样式表中使用hack\9例如: #container { height: 200px\9; } 但是这个特定的高度是由JQuery生成的,例如: $('#container').css({'height': containerheight}); 对于IE,我需要添加hack,因此我尝试: var iecontainerheight = height + 'px\9;'; $('#container').css({'height': iecont
\9
例如:
#container {
height: 200px\9;
}
但是这个特定的高度是由JQuery生成的,例如:
$('#container').css({'height': containerheight});
对于IE,我需要添加hack,因此我尝试:
var iecontainerheight = height + 'px\9;';
$('#container').css({'height': iecontainerheight});
但这是行不通的
有人知道如何正确地使用css()包含该黑客吗?您应该删除
代码>来自“px\9;”。这是无效的
也可以试试这个:
var iecontainerheight = height + '\9';
$('#container').css({'height': iecontainerheight});
您还可以尝试使用jQuery检测浏览器。它只适用于IE浏览器
if (m_BrowserName == "Microsoft Internet Explorer" && m_BrowserVersion.indexOf("MSIE 7.0") > 0){
//your css goes here
}
如果要使用脚本更改高度,为什么不执行浏览器检测,然后指定正确的高度\9
的作用是什么?我在IE7中从未遇到过身高问题