How to check if HTML style attribute exists with javascript

I’m trying to find out if a specific element has an inline style attribute or not:
I’m sure there’s an easy method to check this, but I can’t seem to find it.
I tried multiple things already including this:

var contentWrapper = document.getElementById("contentWrapper");
if(contentWrapper.style.display.toString=="")
alert("Empty");
else
alert("Not Empty");

Thank you for your help!

28 thoughts on “How to check if HTML style attribute exists with javascript”

Leave a Comment