我正在创建ajax调用的动态帖子数据,我也在创建复选框。但是复选框是不可点击的。它显示在文件上,但点击时没有响应。不显示勾选,我指的是用户点击时勾选和未勾选的状态。除了复选框外,一切正常。我还没有为复选框做任何jquery。在控制台我选中复选框html和id值等显示正确这是我的代码//
if(mysqli_num_rows($result) > 0){
$output = "";
$output .= "<div class='col-12'><p id='content-title'>Fresh Posts</p></div>";
while($row = mysqli_fetch_assoc($result)) {
$title = substr($row['title'],0,25) . '...';
$description = substr($row['description'],0,200) . '...';
$output .= "<div class='col-4'>
<div class='post-content'>
<a href='single-post.php?id={$row['post_id']}' class='post-img'>
<img src='dashboard/uploads/{$row['post_img']}'>";
if(isset($_SESSION['logged-in'])){
$output .= "<input type='checkbox' id='{$row["post_id"]}' value='{$row['post_id']}' class='fav-icon-checkbox'>
<label for='{$row["post_id"]}'><i class='fa fa-heart fav-icon'></i></label>";
}
$output .= "</a>
<div class='post-info-container'>
<div class='post-info'>
<span class='post-author'><a href='#'>{$row['author']}</a></span>
<span class='dot'></span>
<span class='post-category'><a href='category.php?id={$row['category_id']}'>{$row['category_name']}</a></span>
<br>
<span class='post-date'>{$row['date']}</span>
</div>
<h5 class='post-title'>{$title}</h5>
<p class='post-description'>{$description}<a href='single-post.php?id={$row['post_id']}' class='read-more'>read more</a></p>
</div>
</div>
</div>";
}
echo $output;
}
检查复选框的value属性尝试更改单引号::$row["post_id"]