Jquery 删除特定div
我想使用jQuery删除Jquery 删除特定div,jquery,html,css,content-management-system,Jquery,Html,Css,Content Management System,我想使用jQuery删除div中的特定div。我怎么做?这是我的密码: echo "<div class=\"da-slide\"> <h2>".$OPST."</h2> <p>".$OPSC." </p> <div class=\"da-img\"> <input onclick='SLIDE_EDIT($OPID);' class=\"slideedit\" type=\"b
div
中的特定div
。我怎么做?这是我的密码:
echo "<div class=\"da-slide\">
<h2>".$OPST."</h2>
<p>".$OPSC."
</p>
<div class=\"da-img\">
<input onclick='SLIDE_EDIT($OPID);' class=\"slideedit\" type=\"button\" value=\"EDIT\">
<input onclick='SLIDE_DELETE($OPID);' class=\"slidelete\" type=\"button\" value=\"DELETE\" >
<input id=\"$OPID\" onclick='SLIDE_HIDE($OPID);' class=\"slidehide\" type=\"button\" value=\"$OPSS\" >
".$OPSI."
</div>
最好使用jQuery事件处理程序 因为您有一个内联事件处理程序,所以将单击的元素引用传递给delete函数,以便删除它
<input onclick='SLIDE_DELETE($OPID, this);' class=\"slidelete\" type=\"button\" value=\"DELETE\" >
为什么要使用AJAX删除元素?
<input onclick='SLIDE_DELETE($OPID, this);' class=\"slidelete\" type=\"button\" value=\"DELETE\" >
function SLIDE_DELETE(SLIDEID, el) {
$.post('insert_home.php', {
SLIDE_DELETE: SLIDEID
}).done(function (data) {
alert('SLIDE SUCCESSFULLY DELETED');
//you may want to delete the da-slide element which contains the delete button
$(el).closest('.da-slide').remove();
//if you just want to remove the delete button
//$(el).remove()
});
}