Does jquery have an element ready function?

I have an element that has a CSS border, and the problem is that the element is empty until the content is filled with jQuery, but the border is drawn by CSS from the very beginning. I would like to be able to do something like make the visibility of an element hidden until it is ready for display then show the element and border at a time.

Is there any way to achieve this?

Edit: code to display content is contained inside

$(window).load(function() {

}
+5
source share
7 answers

Method 1

One method you could try is to set the element's CSS to display:none;. This will hide the element, and calling the next function will make the element appear when the DOM loads.

$(document).ready(function () {
  // Put all of jQuery code in here
  $("element").show(); // substitute element for whatever is needed
});

, jQuery, display:none; ,

<

2

, , - visibility:hidden. , , . , , . , .css(), .show() CSS display:block; , :

$(document).ready(function () {
  // Put all of jQuery code in here
  $("element").css("visibility", "visible") // substitute element for whatever is needed
});

CSS , , DOM .

+14

jQuery addClass, , , , , removeClass, display:none;

, document.ready, !

+2

.

 $(function(){
    $('selector').hide(); // Or you can just have display:none
    });

- - div

....
....//some code that fills in your content
...
$('selector').show();
....
....
+2

$(function(){
  // your code here
});

, , DOM . , , , visibility:hidden css.

0

:

$(document.getElementsByTagName('div')[0]).ready(function() {
// do stuff when div is ready
0

:

$('#element').bind("DOMSubtreeModified", function () {
    //do stuff
});
0

.css()? css . .

, .

-2

All Articles