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

272
Views
edite 'valor px' en elemtn.style.width px usando Javascript

Obtuve una función que obtiene el tamaño del usuario y crea el div, pero no estoy seguro de cómo expresar el tamaño delante de px.

 function createDiv(size) { const div = document.createElement("div"); div.classList.add("box"); div.style.width = `${size} px`; div.style.height = `${size} px`; console.log(size); return div; }

Funciona si ingreso el tamaño como 75px:

 function createDiv(size) { const div = document.createElement("div"); div.classList.add("box"); div.style.width = "75px"; div.style.height = "75px"; console.log(size); return div; }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Debe eliminar el espacio entre el valor y px , debería ser así: ${size}px .

 function createDiv(size) { const div = document.createElement("div"); div.classList.add("box"); div.style.width = `${size}px`; div.style.height = `${size}px`; document.body.appendChild(div); } createDiv(100);
 .box { background: lawngreen; }

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!