I’m developing a JS functions to handle it in $(document).ready(...).
These functions are in file “a.js”.
In function “example(TAG_ID)” I call:
console.log( $('#anything').children().length )
OK. When I include in Application Main Javascrip file: $(document).ready(example(TAG_ID)), is returned: 0
But. When I include <script>$(document).ready(example(TAG_ID))</script> after the element whose id is TAG_ID, is returned: 7 (as it should be)
Description of jQuery.ready() function is: “Specify a function to execute when the DOM is fully loaded.”
I think it is not running after the elements are fully loaded… Why?
evaluates
example(TAG_ID)immediately. As the docs you quoted say, what you want to do is pass a function toready()for it to run when the DOM is ready, which will defer the evaluation: