【发布时间】:2016-12-01 10:35:59
【问题描述】:
我在这里找到了很多关于这个问题的答案,但在 Chrome 中没有任何效果,但它们在 Firefox 中有效..
我正在尝试使用 js/jQuery 增加 div 的高度。在 Chrome 中,它会增加高度,但我无法向下滚动。 这是我尝试做的。
function h() {
document.getElementById('d').setAttribute("style", "height:1500px");
}
<button onclick="h()" class="btn btn-info">Select All videos</button>
<div id="d">
Foo
</div>
我也尝试了 jQuery $("#d").css("height","1500px");,但我无法弄清楚为什么向下滚动不起作用。
【问题讨论】:
-
您在上面显示的效果很好 - 正如您从我添加的用于演示您的代码的 sn-p 中看到的那样。您是否在父元素上设置了
overflow: hidden?另外,检查控制台是否有错误 -
如果正确且有效,您的代码会脱离上下文。 jsbin.com/ronotiqewi/edit?html,css,output
-
不,没有这样的。
-
我看到它在 Chrome 中正常工作。
-
哇。是的,我也能看到。但是为什么我的浏览器看不到它?有什么想法吗?
标签: javascript