admin管理员组文章数量:1394191
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.
本文标签: javascriptPolymer 10 How to get the id of the clicked paper buttonStack Overflow
版权声明:本文标题:javascript - Polymer 1.0 How to get the id of the clicked paper button? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744763001a2623864.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论