以下方法不起作用:
<!DOCTYPE HTML>
<title>Test</title>
<embed id="foo" src="http://www.w3schools.com/media/bookmark.swf" width="400" height="40" type="application/x-shockwave-flash" />
<script type="text/javascript">
document.getElementById("foo").setAttribute("bgcolor", "#00FF00");
</script>
但是如果将 setAttribute 更改为 ("width", "800"),它就可以正常工作!我错过了什么?
最佳答案
document.getElementById("foo")
.setAttribute("style", "background-color: #00FF00;");
宽度
是一个属性。 background-color
是一种样式,应该这样放置
关于javascript - 设置bgcolor属性值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6792044/