【发布时间】:2017-05-17 21:54:38
【问题描述】:
我在尝试选中和取消选中复选框时遇到了一个小问题。当我检查它时,它显示以下图片:
它应该出现按钮,删除,重命名和共享,附加到上传和新文件夹。但是取消选中后我无法删除附加。
我的代码如下:(jQuery)
var ids = <?php echo json_encode($arr); ?>;
for(i = 0; i < ids.length; i++) {
var sel = $("input[id='" + ids[i] + "']");
$(sel).on('click', function(e) {
e.stopPropagation();
$.each(sel, function( sel ) {
if($(sel).is(':checked')) {
$("#del").remove();
$("#rename").remove();
$("#sharing").remove();
$(sel).prop('checked', false );
} else {
$(sel).prop('checked', true );
$("#del").remove();
$("#rename").remove();
$("#sharing").remove();
$(".sub-menu-files ul").append("<li class=\"delbtn\"><button id=\"del\">Delete File</button</li> <li class=\"renamebtn\"><button id=\"rename\">Rename</button></li> <li class=\"sharingbtn\"><button id=\"sharing\">Sharing</button></li>");
$("#del").click(function() {
var sels = $("tbody tr input");
$(sels).each(function() {
if($(this).is(':checked')) {
alert($(this).attr('id') + " has been deleted");
$.post("delete.php", {id: $(this).attr('id') }, function(data) {
if(data != "") {
alert("Your file/files have been sent to the Trash. To delete them from our server, go to \"Deleted Files\" and delete it.");
}
});
}
});
});
}
});
});
}
ids 将在数据库中选择上传文件的 ID。我尝试了一切,但没有任何好处。
我的 php + HTML 内容是:
<td><input type="checkbox" name="select" class="case" id="<?php echo $rows['id']; ?>" style="cursor: pointer;" /></td>
也在挑选id。
有没有办法让它工作?
【问题讨论】:
标签: javascript php jquery html checkbox