0
以下代码有什么问题?动态检测滚动条
我需要根据其他元素是否有滚动条来检测和设置1元素的宽度。这似乎不工作:
console.log("print Scroll..here...");
if(($(".printer-details-container").offsetHeight < $(".printer-details-container").scrollHeight) || ($(".printer-details-container").offsetWidth < $(".printer-details-container").scrollWidth)){
// your element have overflow
console.log("print Scroll..here...");
$(".printer-header").css({"width":"96.9999%;"});
}
else{
//your element don't have overflow
console.log("no print Scroll..here...");
$(".printer-header").css({"width":"100%;"});
//console.log($(".printer-header").print-header.css({"width":"100%;"});
}
什么是不工作?你能提供一个小提琴吗? – Rayon
条件不起作用,我们没有看到宽度设置! – Smitha