Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove input filed value onclick [closed]

I want to remove input filed value while click on button.How can i do that.

For example

<input type="text" name="text"> /***************IF value =Akram ************/
<input type="button">
like image 581
Affan Ahmad Avatar asked May 25 '26 11:05

Affan Ahmad


1 Answers

You can use an html only solution, when you put your input elements in a form

<form>
    <input type="text" name="text" />
    <input type="reset" />
</form>

JSFiddle

And here is a Javascript version

<input id="text" type="text" name="text" />
<input id="button" type="button" />
var text = document.getElementById('text');
var button = document.getElementById('button');
button.onclick = function() {
    text.value = '';
}

JSFiddle

like image 116
Olaf Dietsche Avatar answered May 27 '26 23:05

Olaf Dietsche



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!