Run script after Jquery finish
- by Felipe Fernández
First let's explain the hack that I was trying to implement.
When using Total Validator Tool through my web page and I get following error:
[WCAG v1 6.3 (A), US-508-l] Consider providing a alternative after each tag
As my page relies heavily on javascript I can't provide a real alternative, so I decided to add an empty noscript tag after every script appearence. Let's say I need to provide a clean report about accesibility about my web page even the hack is senseless. (I know the hack is unethical and silly, let's use it as example material, but the point of my post are the final questions)
I tried the following approach:
$(document).ready(function(){
$("script").each(function() {
$(this).after("<noscript></noscript>");
});
});
The problem raises because I have a jQueryUI DatePicker component on my page. jQuery adds a script section after the DOM is ready so my hack fails as miss this section.
So the questions are: How handles jQuery library to be executed after document is ready? How can I run my code after jQuery finish its labours?