function myPow(a,n){
var ret = 1
var i
for (i = 0i<ni++){
ret = ret * a
}
return ret
}
</script>
<input type="button" value="click me" onclick="alert(myPow(10,3))">
<!DOCTYPE html><html>
<head>
<title></title>
</head>
<body>
<div>
<span>初始值:</span><input type='number' id='number' value='1' placeholder='请输入初始值'/>
</div>
<div>
<span>乘次数:</span><input type='number' id='input'/><button onclick='getValue()'>求值</button>
</div>
<div>值等于:<span id="value"></span></div>
</body>
<script type="text/javascript">
function dom(id)
{
return document.getElementById(id)
}
function getValue()
{
var v = parseInt(dom('input').value)
var n = dom('number').value - 0
if(!n||isNaN(n)){
dom('value').innerHTML = '请输入初始值数字'
return
}
if(!v||isNaN(v)){
dom('value').innerHTML = '请输入乘次数数字'
return
}
dom('value').innerHTML = parseFloat(n*Math.pow(0.1,v)).toFixed(v)
}
</script>
</html>