textarea 的value()和innerHTML()的区别

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<script type="text/javascript">
//<![CDATA[
function log(value){

alert(value);

}
function $(id) {

return document.getElementById(id);
} // End of $
function f1(){
log("f1");
$("t1").value = "&lt;aabc&gt;"
$("t2").innerHTML = "&lt;aabc&gt;"
}
function f2(first_argument) {
log("f2");
log("1-->"+$("t1").value);
                        //print "&lt;aabc&gt;"
log("2-->"+$("t2").value);
                        //print "<aabc>"
log("3-->"+$("t1").innerHTML);
                        //print  ""
log("4-->"+$("t2").innerHTML);
                        //print "&lt;aabc&gt;"
} // End of f2
//]]>
</script>
<body>
<textarea name="t1" rows="10" cols="10" id="t1" >
</textarea>
<textarea name="t2" rows="10" cols="10" id="t2" >

</textarea>
<button name="b1" type="button" value="set"  onclick="f1()">Button Text</button>
<button name="b2" type="button" value="get"  onclick="f2()">Button Text</button>

</body>
</html>

你可能感兴趣的:(innerHTML)