我正在尝试使用 jquery 删除 div,但我不知道如何引用 ID,因为它是 PHP var: id="delete$count"
我的Javascript代码:
<script type="text/javascript">
function deleteFile(fname,directory)
{
$.ajax({ url: "delete_img.php",
data: {"file":fname,"directory":directory},
type: 'post',
success: function(output) {
alert(output);
$('div').remove();
}
});
}
</script>
我的PHP代码:
$count=1;
echo '<div class="gallery-item" id="delete$count"></div>';
echo "<div><a class='ico ico-delete' rel='9' rev='2' href='#'onclick='deleteFile(\"$file\",\"$directory\")'>
</a></div>";
$count++;