[英]javascript form submit change submit button image
Here is my problem when i press the submit button in form the submit button change its image background css.这是我在表单中按下提交按钮时的问题,提交按钮更改其图像背景 css。 however when i use mouseup to change its image again back to default it does not effect.但是,当我使用 mouseup 再次将其图像更改回默认值时,它不起作用。
javascript code javascript码
window.onload = searchInit;
function searchInit(){
document.getElementById('search_form').onsubmit = processForm;
document.getElementById('submit_s').onmousedown = submitImageChange;
document.getElementById('submit_s').onmouseup = submitImageDefault;
}
function processForm(){
var a = document.getElementById('search_text');
if(a.value.length > 0){
return true;
}else{
return false;
}
}
function submitImageChange(){
this.style.backgroundImage = 'url(\'../image/button_background.jpg\')';
}
function submitImageDefault(){
this.style.backgroundImage = 'url(\'../image/button_background2.jpg\')';
}
I hope you can help me..我希望你能帮帮我..
Thank you谢谢
use css to change the background on the active state of the button:使用 css 更改按钮的活动 state 上的背景:
#submit_s {
background: url('../image/button_background2.jpg');
}
#submit_s:active {
background: url('../image/button_background.jpg');
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.