Fungsi onClick yang sama pada elemen yang berbeda dan mengubah elemen lain
<button type="button" onclick="myFunction(this)" id="1">Button1</button>
<button type="button" onclick="myFunction(this)" id="2">Button1</button>
<button type="button" onclick="myFunction(this)" id="3">Button1</button>
function myFunction (button) {
var x = button.id;
switch (x) {
case '1':
myFunction1(x);
break;
case '2':
myFunction2(x);
break;
case '3':
myFunction3(x);
break;
default:
return false;
}
}
Wide-eyed Weasel