码迷,mamicode.com
首页 > Web开发 > 详细

html 用图片代替重置按钮

时间:2014-11-27 09:17:42      阅读:188      评论:0      收藏:0      [点我收藏+]

标签:html   css   javascript   

提交时,若把按钮设置成图片提交特别方便只要 <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; 
width: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>

效果如图

bubuko.com,布布扣

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

html 用图片代替重置按钮

标签:html   css   javascript   

原文地址:http://blog.csdn.net/unflynaomi/article/details/41528835

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!