Is there was correct syntax to use jQuery’s $().ready to check whether the DOM is ready, rather than create a callback function once the DOM has loaded?
For example, I want to run different code if the DOM is ready.
function checkDOMReady()
{
if ($(document).ready)
alert("The DOM was ready when this function was called");
else
alert("The DOM was NOT ready when this function was called");
}
Is this valid? If not is there a correct way of doing this?
EDIT:
I am well aware of $(document).ready(function(){}); and the like, but this is not what I am looking for. I have a script that runs every 10 minutes, including when the page is initially loaded, and I want to run different code if the document is ready, and other code if it is not. I could store this data in a global/static variable, but I would like to know whether it is possible simple evaluate a Boolean expression to check if the DOM can be manipulated.
I don’t see why you’d want to do this. In any case, you can have a variable that is set in the document ready callback and check the variable.