Jquery, JSON auto update DIV class real-time

I have a site which displays real-time data that updates every 3 seconds. What I'd like to do is if a JSON value goes below a certain number, that I display a DIV at the top of the screen with a specific class included on it (turning background a specific color and font different color). THen when the number gets higher than the set value, the DIV would be hidden, the page would jump back up into position and it would be like the DIV was never there.

In my css I had made 2 classes.. one with BG color, and display:block, and the other with an all white BG color, and display:hidden.  

I then tried to use the .addClass feature but it doesn't appear to be updating.

Can someone write up a quick example that I can follow?
Who is Participating?
MrBaseball9Author Commented:
I just got it to work. I think I was writing the remove class part wrong.
if(queue < 1)
then I had my setTimeout set to 3 secs
This would help you!



<div id="mydiv" class="class1">test</div>
<input type="button" value="switch" onclick = "document.getElementById('mydiv').className = 'class2';">

Open in new window

Thats cool...
Albert Van HalenAnalyst developerCommented:
NB display:hidden is not correct.
Use display:none
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.