当我点击某个按钮时,不会删除父div,也不会调用任何内容。
我的JavaScript部分:
<script>
$(document).ready(function()
{
$('.delete').click(function() {
var parent = $(this).closest('div');
$.ajax({
type: 'get',
url: 'delete.php', // <- replace this with your url here
data: 'ajax=1&delete=' + $(this).attr('id'),
beforeSend: function() {
parent.animate({'backgroundColor':'#fb6c6c'},300);
},
success: function() {
parent.fadeOut(300,function() {
parent.remove();
});
}
});
});
});
我的HTML部分
<div>
Some name
<button type="submit" class="delete" value="Delete" id="multipleValues">Delete</button>
</div>
这个div在Jquery dynatree扩展
中答案 0 :(得分:1)
<script>
$(document).ready(function () {
$(document).on('click', '.delete', function () {
var this = $(this);
$.ajax({
type: 'get',
url: 'delete.php',
data: {some_data:data},
beforeSend: function () {
this.closest('div').animate({
'backgroundColor': '#fb6c6c'
}, 300);
},
success: function (data) {
this.closest('div').fadeOut(300, function () {
this.closest('div').remove();
});
}
});//ajax ends
});//click event ends
});//dom ready ends
<script>