87,915
社区成员
发帖
与我相关
我的任务
分享
<script type="text/javascript">
var counter = 0;
function f1() {
counter ++;
alert('这是第' + counter + '次调用f1()');
}
</script>
<a href="#" onclick="f1();">点我</a>
<html>
<head>
<script type="text/javascript">
function initDom(){
document.getElementById('click_1').count = 0;
}
function clickCount(e,obj){
if(e.type == 'click'){
obj.count ++ ;
}
alert('已经点击(函数调用)了'+ obj.count+'次' )
}
</script>
</head>
<body onload="initDom();">
<input type="text" id="click_1" onclick="clickCount(event,this)"/>
</body>
</html>