Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
193
rated 0 times [  194] [ 1]  / answers: 1 / hits: 55871  / 13 Years ago, mon, july 4, 2011, 12:00:00

Is there a way of checking if the HTML DOM element/s for a given selector/element are ready yet using jQuery or JavaScript?



Looking at the jQuery api for the ready function it looks like it can only be used with the document object. If ready cannot be used for this purpose is there another way of doing this?



e.g.



 $('h1').ready(function()
{
//do something when all h1 elements are ready
});


Obviously I could use



$(document).ready(function()
{
//do something when all h1 elements are ready
});


But if all the h1's load first then the code specific to h1 elements will only execute after the whole document is ready even though it could actually execute earlier.


More From » jquery

 Answers
10

Edit 2012
The live method is deprecated as of jQuery 1.7.0. The .on() event is now recommended for attaching event handlers. This replaces .bind(), .delegate(), and .live().



See the docs: http://api.jquery.com/on/






Original Answer



i think jQuery .live() event might be what you're looking for.


[#91366] Friday, July 1, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
donovanjasek

Total Points: 465
Total Questions: 103
Total Answers: 113

Location: Saint Vincent and the Grenadines
Member since Thu, Oct 15, 2020
4 Years ago
;