我正在尝试向li
通过 jQuery 添加到 DOM 的单击处理程序添加。我认为这就是你这样做的方式:
jQuery('.deleteUpload').on('click', '.deleteUpload', function() {
var strDocId = jQuery(this).prop('id');
//if (confirm('Are you sure you want to delete this resource') == true) {
$.post('/study-clubs/meetings/delete-upload', {strDocId : strDocId},
function(objData){
console.log(objData);
}
);
jQuery('li#' + strDocId).remove();
//}
return false;
});
这是我的标记:
<li class="pdf deleteLi" id="<?php echo $this->escape($this->objDocRow->id); ?>">
<label><input type="radio" name="documents[1]" value="0" /> Pre-Meeting</label>
<label><input type="radio" name="documents[1]" value="1" /> Post-Meeting</label>
<label><input type="radio" name="documents[1]" value="2" checked /> Do Not Use</label>
<a href="#" class="deleteUpload" id="2">Delete</a>
<a href="/..."><?php echo substr($this->escape($this->objDocRow->doc_title), 0, -4); ?></a>
</li>
当li
您单击a
带有deleteUpload
. 我究竟做错了什么?当我点击它时,我被带到了页面的顶部。我也尝试过deleteLi
而不是deleteUpload
在 jQuery 中,但这也不起作用。