在下面的脚本中,重置按钮的作用也类似于提交按钮。问题可能出在哪里?谢谢。
HTML
<input type="image" name="submit" value=" " src="image.png">
<input type="image" name="reset" value=" " src="reset.png">
谢谢你的时间。
Inputs of type image always act like submit buttons.
You can use JavaScript to override the default behaviour, but if the user does not have JavaScript enabled, the button will submit instead of reset.
An option would be to add a regular reset typed button and replace that with an image or image typed input with JavaScript after DOM is loaded. This would make it work on browsers without JavaScript (they get the default reset button) as well as with JavaScript enabled.
That is the intended behavior.
The input element with a type attribute whose value is "image" represents either an image from which the UA enables a user to interactively select a pair of coordinates and submit the form, or alternatively a button from which the user can submit the form.
Source: http://www.w3.org/TR/2012/WD-html-markup-20120329/input.image.html
要制作重置按钮,您应该使用
<input type="reset" value="Reset">
具有type="image"
提交按钮之类的行为。