简体   繁体   中英

Get Input tag Attribute ID name at Runtime in Meteor JS

I need to get input tag Attribute ID name at run time in Meteor js. I was developed one sample example as shown below.

HTML code :

<body>

  {{>ui}}<br>
</body>

<template name="ui">
<input type="button" value="" id="btn1"/>
<input type="button" value="" id="btn2"/>
</template>

JS Code :

Template.ui.events
({
    'click input' : function (event)
    {
      // template data, if any, is available in 'this'
      if (typeof console !== 'undefined')
         //get input tag Attribute ID name here
        console.log("Get input button id here");
    }
  });

I am new to Meteor, I don't have any idea about this so please help me.

With plain JS you can write :

event.currentTarget.id

With jQuery :

$(event.currentTarget).attr("id")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM