当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - Why can I set the text in a textbox but I can't clear it?

问题描述:

I have this written in a certain Javascript function.

document.getElementById("textbox").innerHTML = "some text";

This does what you'd expect. However, if I slightly modify it to try to clear the text box like this

document.getElementById("textbox").innerHTML = "";

It doesn't work. Why?

网友答案:

I'm not sure why innerHTML is working in that particular case but the more appropriate property to use is value

document.getElementById('textbox').value = '';
网友答案:

Try

document.getElementById("textbox").value= "";
分享给朋友:
您可能感兴趣的文章:
随机阅读: