开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜