html元素中,我們在textarea元素中輸入的內容,是沒有樣式的,如果想要輸入的字體有顏色或者加粗,等等樣式,如何實現呢?可以用div來實現,示例如下:
<textarea id="test"></textarea>
<script language="javascript">
var str="<font><b>abcde</b></font>";
txt=document.createElement('DIV');
txt.innerHTML=str;
test.appendChild(txt);
window.οnbefοreunlοad=function oLoad(){document.location.reload()}
</script>