如何在流星中获取自定义属性值?

How can get custom attribute value in meteor?

如何获取选中的"key"属性的值?

Html代码:

<input type="checkbox" class="each-tab-1" key="some1" value="456">
<input type="checkbox" class="each-tab-1" key="some1" value="789">
<input type="checkbox" class="each-tab-1" key="some2" value="890">
<input type="checkbox" class="each-tab-1" key="some2" value="901">
<input type="checkbox" class="each-tab-1" key="some1" value="012">

JS代码:

'click .action' : function(event, template){
    $("input[class^=each]:checked").each(function(){
        console.log(this.value);
        console.log(this.attr('key')); **// giving error "Uncaught TypeError: undefined is not a function"**
    });
}

只需用 $(this)

将底部包裹起来
$("input[class^=each]:checked").each(function(){
    console.log(this.value);
    console.log($(this).attr('key')); // giving error "Uncaught TypeError: undefined is not a function"**
});