-2
这是我的代码:如何通过javascript在textarea字段中插入图像?
JS
<Script Language="JavaScript">
function add1(x)
{
var oImg=document.createElement("img");
oImg.src=x;
document.getElementById("test").appendChild(oImg);
}
</Script>
HTML
<body>
<div>
<textarea id="test" rows="10" cols="50"></textarea>
<input type="radio" name="emotion" id="sad" />
<label for="sad"><img src="images/tango_face_sad.jpeg" alt="I'm sad" onclick="add1(this.src)" /></label>
<input type="radio" name="emotion" id="happy" />
<label for="happy"><img src="images/blush.jpeg" alt="I'm happy" onclick="add1(this.src)"/></label>
</div>
</body>
它运行在IE罚款,但在Firefox一点儿也不工作。我的代码中有什么问题?
你不能把一个'textarea'内的'img'。 – melancia 2014-12-19 11:12:58
[HTML:有没有什么方法可以在textarea中显示图像?](http://stackoverflow.com/questions/3793090/html-is-there-any-way-to-show-images-in- a-textarea) – melancia 2014-12-19 11:13:29
但它适用于IE。Firefox会出现问题。 – user3855182 2014-12-19 11:19:02