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

143
Views
JS no puede establecer la propiedad de estilo

Ok, veamos esta parte del código:

 $(tbody).find('tr').each((i, oldTbodyTr) => { newTr = document.createElement('tr'); $(oldTbodyTr).find('td').each((i, oldTd) => { let newTd = document.createElement('td'); newTd.innerHTML = oldTd.innerHTML; newTd.classList = oldTd.classList; newTd.style = oldTd.style; //Doesn't work newTr.appendChild(newTd); }); newTableTbody.appendChild(newTr); });

Crea un nuevo cuerpo de tabla recorriendo todas las filas en tbody de una tabla ya existente. Todo está bien, excepto que el estilo del antiguo td no se transfiere al nuevo elemento td . No puedo entender por qué.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Si desea copiar estilos en línea, puede probar newTd.style.cssText = oldTd.style.cssText ya que el style en sí es inmutable.

Ver más sobre style.cssText .

 const source = document.getElementById('source'); const target = document.getElementById('target'); target.style.cssText = source.style.cssText;
 <p id="source" style="color: red; background-color: blue; font-size: 20px;">Source</p> <p id="target">Target</p>

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!