Two Buttons calling same js function.how will know in js function."which button is calling.?"


(Vikrant Arya) #1

button_click.zip (15.4 KB)


#2
console.log(element.id)
alert(element.id)

var textArea = hypeDocument.getElementById('text');
textArea.innerHTML = element.id;

element.id
You get the picture :smile:


(Vikrant Arya) #3

Thank You…DBear :grinning: :grinning:
Now its working fine…
One quick question…
how to add tag in button from identity inspector and how to get tag from button in js,When click on button…


#4

Can you explain what you mean by “tag”?


#5

You assign the button a unique ID here:

… and in your function, you can grab that ID from the event or the clicked element:
var theButtonId = event.target.id;
or
var theButtonId = element.id;


#6

@proberts first problem has been answered and poster knows how to assign an id as he has in his example… Nice pic though :wink:

@vikrantarya any more on what you are referring to when you mean tag?


(Vikrant Arya) #7

@DBear Thank You,That problem was resolved.
@proberts Thank You