Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

141
Visualizações
prev().remove(); is not applying to the previous sibling

I've created li elements and after every li elements there is a div of class crossSign which contains two rectangles making a cross. I want it to when clicked remove it's previous sibling and remove the cross itself. But it's not working when clicked. Can someone tell me what is the problem. And i can't give the html or the css cause im afraid if someone copy it.

    $newform.on('submit', function(e) {
    e.preventDefault();
    var text = $newform.find('input:text').val();
    var url = document.getElementById('addurl').value;
    $list.append('<a href="'+ url +'"><li class="links"><span>' + text +'</span></li></a>');
    $list.append('<div class="crossSign"><div class="line1"></div><div class="line2"></div></div>');
    //$('a').attr('href', url);
    $newform.find('input:text').val('');
    $addurl.val('');
});
$('#close-form').on('click', function() {
    $newform.hide();
    $newlinks.show();
});
$('.crossSign').on('click', function() {
    $(this).prev().remove();
    $(this).remove();
});
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda