Ven*_*kat 0 html javascript meteor
我需要在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");
}
});
Run Code Online (Sandbox Code Playgroud)
我是Meteor的新手,我对此一无所知,请帮助我.
使用普通JS,你可以写:
event.currentTarget.id
Run Code Online (Sandbox Code Playgroud)
使用jQuery:
$(event.currentTarget).attr("id")
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2161 次 |
| 最近记录: |