Sunday, May 12, 2024
 Popular · Latest · Hot · Upcoming
64
rated 0 times [  69] [ 5]  / answers: 1 / hits: 75793  / 11 Years ago, sat, april 27, 2013, 12:00:00

I have a javascript function that tries to determine whether a div is visible and does various processes with that variable. I am successfully able to swap an elements visibility by changing it's display between none and block; but I cannot store this value...



I have tried getting the elements display attribute value and finding if the the element ID is visible but neither has worked. When I try .getAttribute it always returns null; I am not sure why because I know that id is defined and it has a display attribute.



Here is the code of the two different methods I have tried:



var myvar = $(#mydivID).is(:visible);
var myvar = document.getElementById(mydivID).getAttribute(display);


Any guidance or assistance would be greatly appreciated.


More From » jquery

 Answers
3

Display is not an attribute, it's a CSS property inside the style attribute.



You may be looking for



var myvar = document.getElementById(mydivID).style.display;


or



var myvar = $(#mydivID).css('display');

[#78571] Friday, April 26, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
gabriel

Total Points: 323
Total Questions: 107
Total Answers: 108

Location: Federated States of Micronesia
Member since Sun, May 16, 2021
3 Years ago
;