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

166
Visualizações
Modify code contains in variable using JQuery. Remove attribute and wrap by div

I have html in that i have a variable and try to modify it and apply after but after i change it code doesn't change.

So basiclly i have a code with table and i what to remove attribute and wrap by div.

let paste = editor.node.innerHTML;
    //console.log(paste);
    
    console.log($(paste).filter("table"))
    $(paste).filter("table").each(function(i, item){
    
        console.log($(this).attr('width'))
        $(this).removeAttr('width');
        console.log(item)
    })

    editor.node.innerHTML = paste
    console.log(paste)
});

I successfully get that width but after loop i made log and it the same as it was before loop and attribute is still there

Give me an advice please

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Your code

$(paste)

creates a jquery object, this then has the.filter/.each applied to - ie to the jquery object. Not to the source string. The original paste variable is unchanged.

To update your variable, you need to reassign the result of your manipulation, ie:

paste = $(paste)
            .filter("table")
            .each(function(i, item) {
                ...
            })
            .html();
about 4 years ago · Juan Pablo Isaza Relatório
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