Solve the flickering problem of jQuery opening or jumping to the hidden element of the page

Sometimes a problem limits you, often you can change your thinking


The question is as the title implies, my general development requirements are: I have a written page, open it as a pop-up window on another page, and hide the header and side menu bar when opening

The original method has a bug: when opening, the value is passed to determine whether it is from the page or the pop-up window. If it is a pop-up window, add the method of .hide() to the head and side, and the problem is solved, but in the pop-up window When loading, the hidden elements will be loaded first and then hidden. There is a flickering effect, which is not a good experience.

Reason (personal understanding): When the page comes in, the DOM element is loaded first, and then the hide method is called, so there is a flashing effect that is displayed first and then hidden

Solution: On the original page, directly set display:none; css style for the elements that need to be hidden later, and then in js, use the method of passing values/parameters just now to determine which page it is, if it is the original page, let Element show() will do!

Guess you like

Origin blog.csdn.net/qq_44782585/article/details/113180951