<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<tr>
<td align="right">验证码:</td>
<td><label>
<input type="text" />
<span id="yz" style=" background:url(1.png) -10px -15px;80px;font-style: italic; height: 20px;border: 1px solid #ffffff;display: inline-block;"></span>
<a href="javascript:;" id='btn'>看不清</a>
</label></td>
</tr>
</body>
</html>
<script>
function rand( min,max ){
return Math.round( Math.random()*(max-min) + min )
}
fnnum()
function fnnum(){
var newStr = ""
var oSpan = document.getElementById("yz");
var str = "0123456789";
for( var i = 0 ; i < 4 ; i++ ){
var sss = str.charAt( rand ( 0,9 ));
newStr += str[sss]
}
oSpan.innerHTML = newStr ;
}
var oBtn = document.getElementById("btn");
oBtn.onclick = function(){
fnnum()
}
</script>