在这里,我想从 .header
元素中选择 .accept
元素。这可能吗? The documentation尚无定论,我尝试了一些变化但无济于事,是否有我不知道的技巧?
'click .header .accept': function (event) { ... },
在 jQuery 中我可能会使用这个:$('.header .accept')
最佳答案
假设您在其他地方没有冲突,您共享的内容将会起作用。尝试使用下面的代码。仅当您根据需要单击第二个 div 时才会触发该事件。
模板:
<body>
{{> page}}
</body>
<template name="page">
<div class="header">.header
<div class="accept">.header .accept</div>
</div>
</template>
js:
if (Meteor.isClient) {
Template.page.events({
'click .header .accept': function(event) {
console.log('accept clicked');
}
});
}
关于javascript - 是否可以在 Meteor 事件映射中使用嵌套选择器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34915172/