為什么button標(biāo)簽的onclick事件沒有效果,而input可以呢
<form>
<button onclick="chac()">改變顏色</button>
<input type="button" onclick="chac()" value="改變顏色">
</form>
<script type="text/JavaScript">
function chac(){
var new_txt=document.getElementById("txt");
new_txt.style.color="red";
}
</script>
2016-04-01
/*<button onclick="chac()">改變顏色</button>?*/這是什么意思?好像是多余的!
<script type="text/JavaScript">
function chac(){
var new_txt=document.getElementById("txt");
new_txt.style.color="red";
}
</script>
<input name="change"??value="改變顏色"type="button"?onclick="chac()">
//試試吧
2016-04-01
我嘗試的時(shí)候可以的,是不是瀏覽器的問題。