I have a set of paper buttons like below:
<div><paper-button id="100" on-tap="addQuantity">100ML</paper-button><paper-button toggles id="200" on-click="addQuantity">200ML</paper-button><paper-button toggles id="300" on-click="addQuantity">300ML</paper-button></div>
I have a set of paper buttons like below:
<div><paper-button id="100" on-tap="addQuantity">100ML</paper-button><paper-button toggles id="200" on-click="addQuantity">200ML</paper-button><paper-button toggles id="300" on-click="addQuantity">300ML</paper-button></div>
And i want to know the id of each button when clicked. I tried like this in Javascript function. It does not work
addQuantity:function(e)
{
console.log(e.target.id);
}
How to solve this?
Share Improve this question asked Aug 6, 2015 at 22:17 RosAngRosAng 1,0502 gold badges19 silver badges43 bronze badges3 Answers
Reset to default 5Try this -
addQuantity: function (e) {
var button = Polymer.dom(e).localTarget;
console.log(button.id);
}
To get the clicked element id:
addQuantity:function(e) {
var target = e.currentTarget;
var id = target.id;
}
Try using e.srcElement.id
instead.