as eed3si9n said the .hide() call was before the .appendTo() call.
I thought I would just add this answer as I found another way that also works:
jQuery('<div></div>') .css("display", "none") .appendTo(document.body) ;
I don’t know for sure whether this works, but I believe that adding an element to the DOM with it should be faster, since the browser does not need to display it?
An update for those of you that I like and need to know exactly how things work:
Code for jQuery.hide () - comments added by me
hide: function(speed,callback){ return speed ?
and here is the code for the selector :hidden :
hidden: function(a) { return "hidden" == a.type // <input type="hidden" /> || jQuery.css(a, "display") == "none" // style.display = none || jQuery.css(a, "visibility") == "hidden"; // style.visibility = hidden }
This does not actually explain why Chrome does not show the element as hidden, though ...
source share