Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

169
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda