Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 删除特定div_Jquery_Html_Css_Content Management System - Fatal编程技术网

Jquery 删除特定div

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

我想使用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=\"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()
    });
}