javascript - Hiding a div using JQuery -


I want to hide a div using javascript, as soon as the page gets loaded in the browser. Enabled, if I use the following code:

  document.getElementById ("div_id"). Style.display = 'none';  

But, when I try to use JQuery for the same thing, I think that after the page has load the div appears for a few seconds, and then it JQuery code I is used

  $ (document) is hidden .ready (function () {$ ("# div_id"). CSS ('display', 'none') ;});  

If I use $ ("# div_id"), then it happens. Hide (); That's because IM using a library, which will be slow, rather than using a little bit of process directly. GetElementById? .

First, use .> Hide $ ("# div_id") ); . This is more idiotic for jQuery.

Second, this is because you are using $ (document). Usually, until the DOM becomes available for use, it does not float the event. However, the way in which bindReady () is applied, this event may be equivalent to the olload event on some browsers, which is everything < / Strong> Loading Unfortunately, this is the only way I can get around it (which is not the cause of problems for disabled users who can not use JavaScript due to the screen reader) Is (50 milliseconds) and bar-b Check the existence of $ ("# div_id") While the page is loading it is a awesome hack, and I refuse to recommend it, but it does work should do. He said, you are just better about accepting the flash of content, knowing that most users will not see it.


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -