A link equivalent to a reset button?
I want a 'delete link' equivalent of the button type="reset", but not a button, a link. Just like on the youtu开发者_如何学Pythonbe comment box. How is this possible?
You can call the reset
method of a HTML form via Javascript:
<form id="myform">
<input type="text"/>
<a href="javascript:document.getElementById('myform').reset();">reset</a>
</form>
Try this like youtube: :)
<textarea id="tarea"></textarea>
<a href="javascript:void(0)" onclick="document.getElementById('tarea').value='';">reset</a>
You can use a normal button <input type="reset" value="Reset" class="textbutton">
, but style it to look like normal text:
.textbutton {
border: 0px;
background-color: inherit;
}
JSFiddle example
If you want it to reset a form with a link, bind an onClick event to the link and have it call the reset() method on the form object.
精彩评论