Reputation: 462
I have been trying to change this div tag's style when an image is clicked, and its not working. First I want to check and see if the style is "display:none;" or "display:block". But when I try to alert the value it returns "undefined" for both when the display is set to none and when it is set to block.
<div id="navbar-mobile-id" style="display:block;" class="navbar-mobile">
This is in my function: (function works when clicked but alerts "undefined")
alert(console.log(document.getElementById("navbar-mobile-id").style.display));
This should alert either "block" or "none"
Upvotes: 0
Views: 119
Reputation: 944455
The return value of console.log()
is undefined
If you want to alert the value of the display
property, then you have to alert that.
alert(document.getElementById("navbar-mobile-id").style.display);
Upvotes: 7