html 用图片代替重置按钮

提交时,若把按钮设置成图片提交特别方便只要 <input type="image" alt="点此提交" src="images/button.png" width=40 height=50>即可,但是重置能不能是图片样子呢?

<input type="image" src="reset.gif" onclick="javascript:document.forms['testForm_2'].reset(); returnfalse;">

大家别再试这种javascript的方式了没有用的,无论怎么return false点击图片进行重试后,依旧是会执行提交操作,

我用设置css样式解决了 jsp代码如下


<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>




<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    
    <title>My JSP 'tagnot.jsp' starting page</title>
    
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
    <style type="text/css">
#bimg 
{
background:url(images/buttonreset.jpg) -60px -40px; 
125px;
height:30px;
border:none;
font-weight:bold;
color:black;
}
</style>
  </head>
  
  <body>
      <form method="GET" action="">
        <input type="text" name="mae" value="wca">
        <input id="bimg" type="reset" value="重置" >
        </form>
  </body>
</html>

效果如图


亲测好使,再也不会提交了,有木有,别的按钮也可以这样

原文地址:https://www.cnblogs.com/unflynaomi/p/4476858.html