小编nzr*_*nty的帖子

如何在php while循环中选择具有相同类名的适当类

while($row = mysqli_fetch_array($stmt)) {
 output .= '<tr>
             <td id=compare><button class=comparison>Search</button></td>
            </tr>
            <tr id=matching class=matching>
             <td colspan=12>None of a data was found</td>
            </tr>'
}
Run Code Online (Sandbox Code Playgroud)

上面显示了我的php部分,下面的代码显示了我的jquery进程.我想要做的是,当我点击一个/任何按钮class=comparison,它会显示隐藏tr这是class=matching基于表的行已选择或点击.但问题是,当我点击按钮时,它会显示所有tr相同的类.

$(".comparison").on("click", function () {
     if($(".matching").is(":hidden")) {
         $(".matching").slideToggle("fast");
     }
     else {
         $(".matching").hide();
     }
});
Run Code Online (Sandbox Code Playgroud)

如何在php while循环中选择具有相同类名的适当类?

php jquery

2
推荐指数
1
解决办法
69
查看次数

标签 统计

jquery ×1

php ×1