I have a(我有一个)
<input type="text" value="A new value">
I need a javascript method to clear the value of the textbox when the focus is on the textbox.(当焦点在文本框上时,我需要一个javascript方法来清除文本框的值。)
How can this be achieved?(怎么能实现这一目标?)
just get element using(只是使用元素)
function name() { document.getElementById('elementid').value = ""; }
you can call this function on onfocus event of textbox and clear the value(您可以在文本框的onfocus事件上调用此函数并清除该值)
2.1m questions
2.1m answers
60 comments
57.0k users