checking and setting inline styles

D

dave8421

Hi,

I'm creating some animation code called on a timer, and depending on
the state I will either hide or show an item.

e.g. I might need to set something like

someElement.style.display = "block"

However, if the style is already set to "block", then is there
potential for the browser to cause flickering or do extra work if
setting the style to "block" when it is done already.

perhaps it is safer to do

if( someElement.style.display != "block" ) {
someElement.style.display = "block";
}

.... but i just don't like adding unnecessary code
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top