删除评论后,我试图添加功能隐藏。但它隐藏了所有评论。但我需要隐藏刚删除的评论。有我的js。
$('.delete_p').click(function(){
var del_id = $(this).attr('id_p');
$.ajax({
type: 'POST',
url: 'delete_post.php',
data:'delete_id='+del_id,
success: function(data){
$('#status .holder'+del_id).fadeOut();
}
});
});
$( ".delete_p" ).click(function() {
$( "#status .holder").hide("slow");
});
我试图添加this
,但它没有帮助。
$( "#status .holder", $(this)).hide( "slow" );
这里是html。太久了。只是用于评论:
<div id="status">
<div class='holder' id_p='<?php echo $post_id; ?>'>
<div class='holder_half'>
<?php
$default_s_pic = "href=/default_picture.png";
echo "<div id='picture'><a href='/$poster_name'>";
if($adder_pic === ""){
echo '<img src="', $default_s_pic, '" alt="', $poster_f_name,'\'s Profile image">';
}else{
echo '<img src="', $adder_pic, '" alt="', $poster_f_name,'\'s Profile image">';
}
echo "
</a>
</div>
<div class='ten'>
<div id='statusname'><a href='/$poster_name'>$poster_f_name</a></div>
<div class='date_time'>$data</div>
<span class='span' data-ft='{"tn":"K"}'>
";
if($posted_place === $deleter || $poster_name === $deleter){
echo "
<button class='delete_p' id_p='". $post_id ."'>x</button>
";
?><script src="delete_post.js"></script>
</div>
</div>
</div>
</div>
答案 0 :(得分:2)
更改此代码:
<div class='holder' id_p='<?php echo $post_id; ?>'>
到此:
<div class='holder<?php echo $post_id; ?>' id_p='<?php echo $post_id; ?>'>