Javascript IMG插入

时间:2011-03-30 22:51:05

标签: javascript html image dom

im_bar = document.createElement("img");
im_bar.id = UPDATE_STATUS_RESPONSE[0]+"_SPLIT";
im_bar.style.display = "block";
im_bar.style.margin = "0px auto 0px auto";
im_bar.src = "graphics/news_feed_line.png";
document.getElementById("SCRIPT_NEWS_FEEDS").insertBefore(im_bar,document.getElementById("SCRIPT_NEWS_FEEDS").firstChild);

可生产

<img src="graphics/news_feed_line.png" style="display: block; margin: 11px auto 0px;" id="2_SPLIT">

问题:为什么输出的保证金与我在javascript中定义的保证金不匹配?

1 个答案:

答案 0 :(得分:1)

您应该使用css类,而不是在javascript中分配所有这些样式。

相关问题