<分区>
编辑问题以包含 desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem .这将有助于其他人回答问题。
关闭 7 年前。
标签 javascript jquery html css
<分区>
编辑问题以包含 desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem .这将有助于其他人回答问题。
关闭 7 年前。
我在 JavaScript 中使用这个迭代来生成一些 >li< 标签。
for ( var i = 0, l = response.items.length; i < l; i++ )
{
//alert(response.items[i].id.videoId);
document.getElementById("thumbs").innerHTML += "<li class='item-thumbs span3 hardstyle'>Shortened for this question</li>";
}
如下图所示,正在生成 >li< 标签,但屏幕保持“白色”。
谁能告诉我为什么会这样?这个脚本位于代码的底部,也许这就是我看不到任何元素的原因,因为页面的其余部分是在我循环访问这个对象之前生成的?
先谢谢你, 斯蒂芬
最佳答案
你应该尝试删除
来自#thumbs 元素的 css 值(至少是第二个!)
#thumbs {height:0px; overflow:hidden;}
在这里比较:https://jsfiddle.net/vtrpyqdL/ (尝试运行这个然后删除 css 部分)
关于javascript - document.getElementById ("foo").innerHTML 打印 HTML 但不可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32914711/
相关文章:
javascript - 使用 AJAX 和 PHP 和 Javascript 自动填充输入文本框
javascript - 无法使用 typescript 创建 react 应用程序
html - 访问 Rails 后端的 Javascript 变量
javascript - 如何让我的垂直导航栏的文本在打开时保持在同一个位置?
javascript - JQuery AJAX 尝试解析 XML,即使使用 "dataType": "JSON"
javascript - 显示 :table and jquery toggle