0
<input type="button" value="button1" id="go" onclick='funcion()'\ >
<input type="button" value="change" id="change"\ >
私はボタンを押したときにボタン1で機能OnClickを変更できますか?ボタンを押す動作を変更しますか?
<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>
'change'ボタンのクリックハンドラ内の変数を設定し、' funcion() 'で変数を調べます。 – Barmar
あなたは何をしようとしているのか詳細を教えてください。どのような動作を変更したいですか? – Barmar
たとえば、初めてbutton1を押すと警告が表示され「1」と表示され、次にボタン1を変更する「変更」ボタンを押します。その機能を変更します –