Disappearing two divs with jquery

0

First of all I made a foreach in my bank but the code will be very extensive continuing, What I want to do is to have the user click on the link to appear a confirmation of a div, in this div will have a link to actually delete the article the problem is when I delete the article,  the div of the article does not disappear just add the div from the template window, and I would like this confirmation window  appears only upon the clicked div. thank you all for helping me and constructive criticism will be welcome

<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript">
$("document").ready(function(){

$('.excluir').click(function(){
    $('.janela-moldal').fadeIn();
});

$('.chamar-moldal').click(function(){
    $('.janela-moldal').fadeIn();
});

$('.cancelar').click(function(){
    $('.janela-moldal').fadeOut();
});

$(".excluir-artigo").live('click',function(){
         $.post('php/deletar.php', {coment:$(this).attr('id')});
         $(this).parent('div').fadeOut();
      $(".janela-moldal").fadeOut();
    };
});

});


</script>

<?php
    $artigo[] = array();
    $artigo['artigo_id'] = 1;
    $artigo['frase'] = '"A vingança nunca é plena, mata a alma e a invenena"';
?>


<div class="artigos" id="artigos"> 
    <?=$artigo['artigo_id']; ?>
    <h1><?= $artigo['frase']; ?></h1>
    <a class="chamar-moldal" href="javascript:void(0);">chamar a div de confirmacão </a>
</div>

<div class="janela-moldal" style="display:none"> 
    <h1>Deseja excluir este artigo?</h1>
    <a class="cancelar" href="javascript:void(0);">cancelar</a>
    <a class="excluir-artigo" id="artigo-<?=$artigo['artigo_id']?>" href="javascript:void(0);">excluir</a>
</div>
    
asked by anonymous 06.01.2016 / 20:46

1 answer

1

Place Modal inside the article div

<div class="artigos" id="artigos"> 
    <?=$artigo['artigo_id']; ?>
    <h1><?= $artigo['frase']; ?></h1>
    <a class="chamar-moldal" href="javascript:void(0);">chamar a div de confirmacão </a>

    <div class="janela-moldal" style="display:none"> 
        <h1>Deseja excluir este artigo?</h1>
        <a class="cancelar" href="javascript:void(0);">cancelar</a>
        <a class="excluir-artigo" id="artigo-<?=$artigo['artigo_id']?>" href="javascript:void(0);">excluir</a>
    </div>
</div>

And when it's time to remove, call parent () twice.

$(".excluir-artigo").live('click',function(){
     $.post('php/deletar.php', {coment:$(this).attr('id')});
     $(this).parent('div').parent('div').fadeOut();  // VOcê pode fazer assim
     //$(this).parent().parent().fadeOut();   // Ou assim
     $(".janela-moldal").fadeOut();
    };
});
    
07.01.2016 / 13:51