1 每次点击,执行函数不同
<body>
<input type="button" id="zhch" value="我的注册函数是hello" οnclick="hello()"/>
<script type="text/javascript">
function hello()
{
alert("hello");
document.getElementById("zhch").value = "我的注册函数是word";
document.getElementById("zhch").onclick = word;
}
function word()
{
alert("word");
}
</script>
</body>
2 第一次点击执行方法1,第二次点击执行方法1和方法2,第三次点击执行方法1、方法2和方法3等等
<body>
<input type="button" id="zhch" value="我的注册函数是hello" οnclick="hello()"/>
<script type="text/javascript">
function hello()
{
alert("hello");
document.getElementById("zhch").addEventListener("click",word,false);
}
function word()
{
alert("word");
}
</script>
</body>