Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

165
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!