我必須刪除整個div,其類「輸入組」。我必須通過jQuery來做到這一點。我嘗試通過jQuery,但div不是刪除。我必須通過jQuery刪除父div
這裏是我的代碼,
$(document).ready(function() {
$(".wrapper").on('click', '.rmvBtn', function(e) {
e.preventDefault();
$(this).parent('div').remove();
x--;
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="wrapper">
<div class="input-group">
<input type="text" class="form-control" name="field_name[]" value="" />
<span class="input-group-addon">
<a href="#" class="rmvBtn" title="Remove field"">
<span class="glyphicon glyphicon-minus"></span>
</a>
</span>
</div>
</div>
請讓我知道在我的代碼有什麼錯誤?提前致謝。
非常感謝,它工作得很好。 –
歡迎@SandeepKumar ...':)'! – vijayP