-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