当用户单击删除时,我想显示一个最近隐藏的div(.wpcf7-字段-组按钮)。我在add上制作了一个脚本,该脚本运行良好,但是我想撤消remove上的hide操作。我该怎么办?
这是我的剧本
date
2018-01-01 50
2018-01-02 -100
答案 0 :(得分:0)
var btnAdd;
function f1(btn) {
var b = $(btn);
if (b.hasClass("wpcf7-field-group-add")) {
//var d = c.data("group-model").clone();
//c.append(d),
//b.trigger("wpcf7-field-groups/added"),
btnAdd = b.closest(".wpcf7-field-group button");
} else {
//b.trigger("wpcf7-field-groups/removed"),
b.closest(".wpcf7-field-group").remove();
}
if(btnAdd instanceof jQuery)
btnAdd.toggle();
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="wpcf7-field-group">
<button class="wpcf7-field-group-add" onclick="f1(this)">Add</button>
</div>
<div class="wpcf7-field-group">
<button class="wpcf7-field-group-remove" onclick="f1(this)">Remove</button>
</div>