Return the font weight of a <p> element:
alert(document.getElementById("myP").style.fontWeight);
<!DOCTYPE html> <html> <body> <p id="myP" style="font-weight:bold">This is a paragraph.</p> <button type="button" onclick="myFunction()">Return font weight</button> <p id="demo"></p> <script> function myFunction() {/* w w w .j a v a 2 s . co m*/ document.getElementById("demo").innerHTML = document.getElementById("myP").style.fontWeight; } </script> </body> </html>