How to clear a textbox using javascript

前端 未结 15 2145
失恋的感觉
失恋的感觉 2020-12-05 09:45

I have a


I need a javascript method to clear the value of the textbox when the focus is

相关标签:
15条回答
  • 2020-12-05 10:30

    For those coming across this nowadays, this is what the placeholder attribute was made to do. No JS necessary:

    <input type="text" placeholder="A new value">
    
    0 讨论(0)
  • 2020-12-05 10:30

    use sth like

    <input type="text" name="yourName" placeholder="A new value" />

    0 讨论(0)
  • 2020-12-05 10:32

    Your HTML code,

    jquery code,

    $("#textboxID").val('');

    0 讨论(0)
提交回复
热议问题