function myFunction() {
alert(document.getElementById("myP").style.color);
}
#myP {
color: pink;
}
<!DOCTYPE html>
<html>
<body>
<p id="myP">This is an example paragraph.</p>
<button type="button" onclick="myFunction()">Return text color of p</button>
</body>
</html>
If I do
<p id="myP" style="color: pink;">This is an example paragraph.</p>
It returns the color value correctly.
How can I get the color value if the value is set in css ?
I need Javascript not JQuery.
Thanks.