Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Polymer 1.0 How to get the id of the clicked paper button?

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?

like image 716
RosAng Avatar asked Dec 02 '25 05:12

RosAng


1 Answers

Try this -

addQuantity: function (e) {
    var button = Polymer.dom(e).localTarget;
    console.log(button.id);
}
like image 107
Justin XL Avatar answered Dec 03 '25 17:12

Justin XL



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!