Hi,
On the html file I have this code:
<button id='A' onClick='getId(this.id)'>A</button>
And on the js file I have this code:
function getId(clicked_id) {
switch(clicked_id) {
case 'A':
IdElement = document.getElementById('A');
break;
case 'B':
IdElement = document.getElementById('B');
break;
}
}
Those IdElement come with a click of a button. But what if I want to assign a ‘C’ id into that the switch function from another javascript function, assuming assignId(), what the code should I compose.
I want the IdElement come from another function (and it’s not a click) when the event is triggered.
Hope I explain it clearly and thanks in advance.