0
Yesterady我问我如何删除我的按钮How to remove the input element before my button?之前的输入,我得到了一个在片段中工作的答案。现在我尝试在我的活动中使用它,但我无法删除该字段,我只能删除该按钮。如何使用.prev与Meteor事件?
Template.myTemplate.events({
'click .removeField': function(event, template){
$(this).prev('input').remove();
$(event.target).prev('input').remove();
$(event.target).prev().prev('input').remove();
$(event.target).remove();
}
的$(event.target)
是i.fa.fa-times
所以我prev().prev('input')
试图在a -> input
我的HTML是下列之一:
<div class="form-style-2">
<div class="form-style-2-heading"></div>
<form action="" method="post">
<label>
<span>Container name
<span class="required">*</span>
</span>
<input type="text" class="input-field nameModif" value="" required/>
</label>
<label id="labelEnv">
<span>Environment
</span>
<input type="text" class="input-field env"/><a class="removeField" aria-expanded="false"><i class="fa fa-times"></i></a>
<a class="addEnv" aria-expanded="false"><i class="fa fa-plus"></i></a>
</label>
</form>
</div>
我可以有'N' ''字段,这就是为什么如果标签中有多个输入,我需要删除那个' ' – Jerome
之前的标签,标签将无法按预期工作。点击标签应该在链接的输入上激发焦点事件。 –
我想要做的事情是在我的''之前删除输入,但我可以有'n'输入 – Jerome