【发布时间】:2018-01-25 12:03:54
【问题描述】:
我编写了代码来生成 html 行。
我现在如何删除它们?这不起作用
$('.deleteEnv').click(function () {
$(this).parents().remove();
});
$('#addEnv').click(function() {
$('#envVariablesDiv').append('<div class="col-sm-5 top10"><div class="input-group"><label class="input-group-addon">Name</label><input id="envName" class="form-control" name="envName" type="text" placeholder="e.g. name1" /></div></div>' +
'<div class="col-sm-5 top10"><div class="input-group"><label class="input-group-addon">Variable</label><input class="form-control" id="envVar" type="text" name="envVar" placeholder="e.g. var1" /></div></div><div class="col-sm-2 top10"><button type="button" class="btn btn-danger deleteEnv"><span class="fa fa-trash">Delete</span></button></div>');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button id="addEnv">Add</button>
<div id="envVariablesDiv">
</div>
【问题讨论】:
-
你已经问过这个问题了。 stackoverflow.com/q/48441993/1288408为什么还要问?
-
@qweq 我强烈建议您阅读一些关于该网站如何运作的指南,例如"What topics can I ask about here?"、"What types of questions should I avoid asking?",更重要的是,请阅读the Stack Overflow question checklist。这不是您第一次在很少的研究工作的情况下提出多个重复的问题,也不是您第一次对那些试图帮助您的人使用辱骂性语言。
标签: javascript jquery html