innerText和innerHtml是用於在頁面上輸出現實的信息的。
也就是說在js裏:var tt=xxx.innerText, tt是空的,要用xxx.value.
例如:
<html>
<head>
<script>
function show(){
var obj = document.getElementById("d");
d.innerText="show text";
}
function message(){
var obj = document.getElementById("e");
alert(obj.value)
}
</script>
</head>
<body>
<div id="d" onClick="show()" >abc</div>
<input type="text" id="e" value="" onBlur="message()"/>
</body>
</html>
對比看看