innerText

来源:互联网 发布:up to date数据库介绍 编辑:程序博客网 时间:2024/04/30 12:56
 
请问我在jsp文件中写了一个js函数用于弹出所输入text1的值,我用:alert(text1.value.innerText)表示为undefinedalert(text1.innerText)表示为空只有alert(text1.value)可以正确表示text1中的值为什么前两种方法不对呢?谢谢!
 
 
 
innerText和innerHtml是用于在页面上输出要现实的信息的。例如:<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>对比看看
 
0 0