
<input
type="button"
value="call"
onclick="showimage()">
</div>
这样是在div中放了一个
按钮
,点击的时候(onclick)调用你写的
'showimage',不知道你要的是不是这样……
当a函数返回false时,b函数会执行的。
如果是这样:
onclick="return a()",当a()返回false时,将取消浏览器默认行为(如打开链接等)。
如果想在a()返回false时不执行b,可以这么做:
onclick="if (a()) b()"这里其实是可以写任何js的代码的。
一般不推荐使用onclick属性,建议使用事件绑定。请参阅js的addeventlistener函数。也可以使用jQuery库进行事件绑定,非常方便。
您的采纳就是我的动力!
<html><head>
<meta http-equiv="Content-Type" content="text/html charset=utf-8" />
</head>
<body>
<div id="times"></div>
<br/>
<input type="button" value="Click" id="click" onclick="ourtimes()" />
</body>
<script>
function ourtimes(){
setInterval(autototime,1000)
}
function autototime()
{
var begintime=new Date(localStorage.getItem("btime"))
var nowtime = new Date()
var t=parseInt((nowtime.getTime()-begintime.getTime())/1000)
d=parseInt(t/3600/24)
h=parseInt((t/3600)%24)
m=parseInt((t/60)%60)
s=parseInt(t%60)
document.getElementById("times").innerHTML="已经开始了:"+d+"天 "+h+"时"+m+"分"+s+"秒"
}
</script>
</html>
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)