Scenario: I have a Javascript-generated web page that someone else wrote a long time ago that I'd like to pretty up using jQuery. My goal is to clean up the Javascript generated html that someone else produces just by using some jQuery calls against that HTML, after it has been generated.
This will be much simpler than modifying the other person's Javascript directly, at least for now.
My first attempt was to just add in a script tag at the end of the HTML head that invokes the desired jQuery code.
<script src="/someone-elses-js-generator.js" />
<script>
$(document).ready(function() {
alert('the other stuff ran, now do the jquery cleanup');
$('.foobar').css("display","none");
$('.doobar').css("display","inline");
/// ... so on and so forth ...
});
</script>
Problem: The above works just fine, but when I comment out the "alert" message. The jquery no longer performs the cleanup. Apparently, what is happening is that the alert msg box was delaying the run of the subsequent cleanup code, which is great, but without the alert, the jQuery seems to run before the other javascript has finished its output.
Question: Is there a way to get the jQuery clean-up code to run after the js-generator code, but without having to put an alert() box in there?