Business
Jobs
  • About Us
  • Solutions
    • Candidates
      Highly qualified candidates in 48h.
    • Assessments
      500+ technical and psychological assessments, plus anti-fraud system.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Pay in 15+ LATAM countries without setting up a local entity.
  • Pricing
  • Jobs

0

371
Views
Obtenga el valor de peso de fuente CSS usando Javascript style.fontWeight.value (sin definir, esperando un valor)

Soy consciente de que el valor a veces podría ser una palabra como "negrita", pero para esto solo estoy usando números y esperaba que la salida mostrara "900", en lugar de eso, obtengo "indefinido".

 document.getElementById("results").innerText = document.getElementById("getfontweightfrom").style.fontWeight.value;
 <div id="getfontweightfrom" style="font-weight:900;"> Test </div> <hr> Result: <div id="results"></div>

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

0

No es necesario agregar .value .

 document.getElementById("results").innerText = document.getElementById("getfontweightfrom").style.fontWeight;
 <div id="getfontweightfrom" style="font-weight:900;"> Test </div> <hr> Result: <div id="results"></div>

about 4 years ago · Juan Pablo Isaza Report

0

Creo que lo que quieres es window.getComputedStyle

 const weight = window.getComputedStyle(elem).fontWeight
about 4 years ago · Juan Pablo Isaza Report

0

Puede usar getComputedStyle()

 elem = document.getElementById('getfontweightfrom'); style = window.getComputedStyle(elem); weight = style.fontWeight; alert(style.fontWeight)
 <div id="getfontweightfrom" style="font-weight:900;">Test<div>

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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!