请大家帮忙改个函数了。
<script language= "JavaScript " type= "text/javascript ">
function aa(k)
{
document.write(k);
}
</script>
<input name= "addd " type= "button " id= "addd " onclick= "aa(6) " value= "增加 ">
我想让按钮点第一次显示6,点第二次显示7,点第三次显示8,…………
这个循环下去,不知道函数要怎么改才行呢,?
用这个setAttribute是不是只能修改属性,这里能不能用呢,请高手帮我解答下吧。谢谢了。
------解决方案-------------------- <script language= "JavaScript " type= "text/javascript "> var num=6; </script>
<input name= "addd " type= "button " id= "addd " onclick= "alert(num++) " value= "增加 ">
超简洁代码
------解决方案-------------------- <script language= "JavaScript " type= "text/javascript ">
function aa()
{
var obj=document.getElementById( "div1 ")
var num=obj.innerText;
obj.innerText=parseInt(num,10)+1
}
</script>
<input name= "addd " type= "button " id= "addd " onclick= "aa() " value= "增加 ">
<div id= "div1 "> 6 </div>