+ 1
[SOLVED] Assign same action on two different buttons on Webpage using Javascript
Can anyone help to merge this two functions or set same action on two different buttons. closeInputBtn[0].onclick = () => { alert() } closeInputBtn[1].onclick = () => { alert() }
2 odpowiedzi
+ 5
closeInputBtn.forEach( btn => {
btn.onclick = () => alert()
})
+ 2
const click = () => {}
btn1.onclick = click;
btn2.onclick = click;