[英]Submit behavior is acting differently when pressing a button compared to pressing enter
[英]Changing behavior pressing a button?
<input type="button" value="button1" id="go" onclick='funcion()'\ >
<input type="button" value="change" id="change"\ >
當我按下按鈕更改時,如何更改按鈕1中的OnClick功能?
document.getElementById("change").onclick = function() { // when clicking #change
document.getElementById("go").onclick = function() { // overide the click event listener of #go
// ...
}
}
<input type="button" value="button1" id="go" onclick='funcion()'\ >
<input type="button" value="change" id="change" onclick='funcion=newFuncion'\>
<script>
function funcion() {
//first action
}
function newFuncion() {
//second action
}
</script>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.