[英]Get Input tag Attribute ID name at Runtime in Meteor JS
我需要在運行時在Meteor js中獲取輸入標簽屬性ID名稱 。 我開發了一個示例示例,如下所示。
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");
}
});
我是Meteor的新手,對此我一無所知,請幫助我。
使用普通的JS,您可以編寫:
event.currentTarget.id
使用jQuery:
$(event.currentTarget).attr("id")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.