我试图通过在a中定义提交按钮来替换提交按钮class="myButton"并更改CSS中的样式.在myButton:active似乎并不被点击时工作.
这是我的CSS:
.myButton{
background:url(./images/but.png) no-repeat;
cursor:pointer;
border:none;
width:100px;
height:100px;
}
myButton:active {
background:url(./images/but2.png) no-repeat;
}
Run Code Online (Sandbox Code Playgroud)
HTML代码:
<input class="myButton" type="submit" value="">
Run Code Online (Sandbox Code Playgroud) 我不太明白这是怎么回事onsubmit="return validate()".为什么我要return这个功能?只有当它return false从语句中检测到一个时才能工作吗?
<script type="text/javascript">
function validate() {
if ((document.example2.naming.value == "") || (document.example2.feed.value == "")) {
alert("You must fill in all of the required .fields!");
return false;
}
else {
return true;
}
</script>
<form name="example2" onsubmit="return validate()">
<input type="submit" name="B1" value="Submit">???????
Run Code Online (Sandbox Code Playgroud)