如何选择既不是父母也不是孩子的div类

时间:2018-10-20 10:55:02

标签: javascript php jquery

我有一个while循环,现在我正在获取用户朋友的帖子,我有一个react列,用户可以在其中选择他的反应表情符号,并且当我单击任何反应时,我想用class react2隐藏div我现在无法选择单击输入类型的react2的div。而且react2 div不是任何反应按钮的父级,这是我的代码

<div class="float2">
    <div class="react2" id="react2" data-rowid="<?php echo $pixid?>">
    <?php
        $query2 = "SELECT * FROM gormint where post_id = $pixid and user_id= $id3";
        $fire2 = mysqli_query($con,$query2) or die("can not fetch data from database ".mysqli_error($con));


        $query3 = "SELECT * FROM bhai where post_id = $pixid and user_id= $id3";
        $fire3 = mysqli_query($con,$query3) or die("can not fetch data from database ".mysqli_error($con));


        $query4 = "SELECT * FROM famer where post_id = $pixid and user_id= $id3";
        $fire4 = mysqli_query($con,$query4) or die("can not fetch data from database ".mysqli_error($con));


        $query5 = "SELECT * FROM muskan where post_id = $pixid and user_id= $id3";
        $fire5 = mysqli_query($con,$query5) or die("can not fetch data from database ".mysqli_error($con));


        if (mysqli_num_rows($fire2)>0) {
            echo "<img src='gormint.jpg' class='gormint2' style='width:30px; height:30px;'  >";
        }elseif (mysqli_num_rows($fire3)>0) {
            echo "<img src='bhai.jpg' class='bhai2' style='width:30px; height:30px;'>";
        }elseif (mysqli_num_rows($fire4)>0) {
            echo "<img src='famer.jpg' class='bhai2' style='width:30px; height:30px;'>";
        }elseif (mysqli_num_rows($fire5)>0) {
            echo "<img src='bancho.jpg' class='bhai2' style='width:30px; height:30px;'>";
        } else{
            echo "<img src='wink.png' class='wink2' style='width:30px; height:30px;'>";
        }
    ?>
</div>

<div class="flipClass" style="display: flex;" data-rowid="<?php echo $pixid?>" id="flip">react</div>


<div class="panelClass" style="" id="panel" data-rowid="<?php echo $pixid?>"> 
  <input type="image" onclick="PlaySound2()" id="display" data-value="<?php echo $users['id'];?>"  src="gormint2.jpg" class="close2 display gormint animated bounceIn " >
</div>

这是我尝试过的脚本

$(document).on('click','.display',function(){


    var value=$(this).attr('data-value');
    $panelClass = $(this).parents('.react2');
    $.ajax({url:"reaction.php?pollid="+value,cache:false,
      success:function(){

       $panelClass.fadeOut();

    }});
}); 

我的脚本不起作用,因为coz react2不是反应按钮的父级,并且尝试了最接近的操作,但它没有任何建议,我该怎么办

0 个答案:

没有答案