t
答案 0 :(得分:1)
这就是您想要的吗?关于您的代码,有很多事情。这里是一些:
$('body').on('click', '.btn-danger', function(e) {
$(this).closest('.question').remove();
});
$('body').on('click', '.btn-success', function(e) {
var $quest = $(this).closest('.question');
$quest.clone().insertAfter($quest);
});
.question {
background-color: lavender;
border: solid 15px darkcyan;
border-radius: 32px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="question container">
<div class="input-group" style="margin-top: 10px">
<input type="text" placeholder="Soru Gir..." class="form-control"/>
<button class="btn btn-danger">Sil</button>
<button class="btn btn-success">Şık Ekle</button>
</div></br>
</div>
答案 1 :(得分:0)
function create() {
$("<div class='question container' style='background-color:lavender; border:solid 15px darkcyan; height:500px; border-radius:32px'><div class='input-group' style='margin-top:10px'><input type='text' placeholder='Soru Gir...' class='form-control'/> <button class='btn btn-danger' >Sil</button> <button class='btn btn-success' onclick='createSelection()'>Şık Ekle</button></div></div></br>").insertBefore("#btn");
}
$('body').on('click','.question .btn-danger', function(){
$(this).closest('.question').remove();
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<input type="button" id="btn" value="create" onclick="create();" />
将此添加到您的javascript代码中:
$('body').on('click','.question .btn-danger', function(){
$(this).closest('.question').remove();
});