if(count($father1)!=0) {
for($i=0;$i<count($father1);$i++) {
if($father1[$i][ 'sbs_f_userid']==$id) {
$pc_pic=$father1[$i][ 'sbs_f_face']. '.'.$father1[$i][ 'sbs_f_format'];
echo '<div class="fpic"><img src="'.$img_loc.'del-but.png" class="myfamily29 dpic f" alt="Click to Delete" title="Click to Delete"/><div class="kpic f"><img src="'.$img_gearup.$pc_pic. '" width="47" height="47" ></div></div>';
?>
我在我的程序中使用此代碼。該類FPIC使一個具有棕色邊框,它有一個父親的圖片和del-but.png圖像。所以當用戶點擊del-but.png時,下面的過程運行。整個div是刪除而不是圖像
$(".dpic").click(function() {
if ($(this).hasClass("f")) {q = father ; var ddpic = $(this).parent('div').find(".kpic").find("img").attr("src"); var that = $(this).parent('.fpic');}
lbox = new LadduBox();
lbox.init({
"width": 485,
"height": 232,
"HTML": '<div style="width:488px; height:235px; background:url('+img_loc+'bg4.png) no-repeat;"><table cellspacing="0" cellpadding="0" border="0" align="center" width="488" height="152" style="font-family:arial; font-size:18px; font-weight:bold; color:#ffffff;"><tr><td align="right" height="50" valign="top" colspan="2"></td></tr><tr><td align="center">Are you sure you want to delete the picture?</td></tr><tr><td align="center"><div class=" abc yes">YES</div><div class="no" id="btnClose">NO</div></td></tr></table></div>',
'btnCloseId': '#btnClose'
});
lbox.fire();
$(".abc").bind("click", function() {
$.blockUI({ message: '<h3>deleting...</h3>', css: {
border: 'none',
padding: '15px',
'z-index': '1991000',
background: 'url('+img_loc+'bg4.png)',
'-webkit-border-radius': '10px',
'-moz-border-radius': '10px',
color: '#fff'
}
});
$.post("delete_pic.php", {
"ddpic": ddpic,
"user": q,
"uid": sbs.userid
}, function (data) {
if (data.result == "1") {
if(q == "kid"){ $(".kidd").find("img").attr('src',''+img_loc+'blank_face.png');}
if(q == "mother"){ $(".mat").find("img").attr('src',''+img_loc+'blank_face.png');}
if(q == "father"){ $(".fat").find("img").attr('src',''+img_loc+'blank_face.png');}
}
that.remove();
setTimeout($.unblockUI, 100);
}, "json");
lbox.closeladdubox();
});
});
}
});
用戶點擊後,會詢問你是否確定要刪除?如果是按鈕,用戶點擊即可全班靈活插卡被刪除
但是,如果我需要刪除圖像只有書房我會做 –
然後,你可以嘗試'that.find('img')。remove()' –
@ PHP_USER1如果你想用其他圖像替換該圖像那麼你可能想嘗試'replaceWith()'http://api.jquery.com/replaceWith/ –