Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unwanted "flickering" effect when using hide and show in jquery

Tags:

html

jquery

I'm getting an annoying "flickering" effect in Firefox when using jQuery "show" and "hide" on some div's. Any idea when this could be happening?

like image 655
craigmoliver Avatar asked Nov 29 '22 06:11

craigmoliver


1 Answers

Depending on what you mean by flicker (if it only flickers when the page loads), instead of doing:

$(document).ready(function(){
   $("hide").hide();
});

<div id="hide">My Hidden Text</div>

Try adding display:none in the CSS:

<div id="hide" style="display:none">My Hidden Text</a>

CSS is applied to the DOM before even JavaScript is allowed to manipulate it, so if you do this, there should be no flicker when you load the page.

Also of note, in Firefox, there is a bug that causes the window to flicker when you change the size of the window (vertically), and the current scroll position is close or at the bottom of the window.

like image 115
Stephen Fuhry Avatar answered Dec 15 '22 05:12

Stephen Fuhry