Return the font weight of a <p> element: - Javascript CSS Style Property

Javascript examples for CSS Style Property:fontWeight

Description

Return the font weight of a <p> element:

Demo Code

ResultView the demo in separate window

<!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>

<script>
function myFunction() {/*  w  w w .j a v a 2  s. com*/
    console.log(document.getElementById("myP").style.fontWeight);
}
</script>

</body>
</html>

Related Tutorials