如何使用id删除div? [英] How to remove div using id ?

查看:143
本文介绍了如何使用id删除div?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究MVC 5,



从文件夹中删除图像后,div包含图像现在正在删除。



I am working on MVC 5,

After remove the image from folder, the div contain image is now removing.

$(document).on("click", ".deleteProImg", function (e) {
    debugger
    if (confirm("Are you sure you want to delete?")) {       

        var imgId = $(this).attr('id');
        var _imgId = imgId.substring(10);       
        $.ajax({
            url: '/Product/DeleteProImage/',
            type: "POST",
            data: { proFileName: _imgId },
            success: function (data) {
                $('#' + _imgId).remove();
            }
        });
    }
    return false;
});





我尝试了什么: < br $> b $ b

查看,





What I have tried:

View,

<div id="uploadedImages">
        <div id="25cb10a7-3ae0-41a7-9b40-964ea0e74308.png"><img id="undefined" src="../Product/Image?imageName=25cb10a7-3ae0-41a7-9b40-964ea0e74308.png" width="135" height="135"> <button class="deleteProImg" id="btnProImg_25cb10a7-3ae0-41a7-9b40-964ea0e74308.png">Delete</button> <input type="hidden" value="25cb10a7-3ae0-41a7-9b40-964ea0e74308.png" name="img_81"></div></div>





如何删除$('#25cb10a7-3ae0-41a7-9b40-964ea0e74308.png')div?



How can I remove the $('#25cb10a7-3ae0-41a7-9b40-964ea0e74308.png') div ?

推荐答案

document )。on( < span class =code-string> click, .deleteProImg,< span class =code-keyword> function (e){
debugger
if (确认( 您确定要删除吗?)){

var imgId =
(document).on("click", ".deleteProImg", function (e) { debugger if (confirm("Are you sure you want to delete?")) { var imgId =


this )。attr(' id');
var _imgId = imgId.substring( 10 );
(this).attr('id'); var _imgId = imgId.substring(10);


.ajax({
url:' / Product / DeleteProImage /'
类型: POST
data:{proFileName:_imgId},
成功:功能(数据){
.ajax({ url: '/Product/DeleteProImage/', type: "POST", data: { proFileName: _imgId }, success: function (data) {


这篇关于如何使用id删除div?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆