Dave's Brain

Browse - programming tips - jquery initialize

Date: 2009apr2
Updated: 2011jun8
Language: javaScript, php, perl

Q.  Where should I initialize my jQuery stuff?

A.  Use document.ready() like this:

	<script>
	$(document).ready(function() {
		// PUT INITIALIZATION HERE
	});
	</script>

Or if you already have a function that you want run do init things do this:

	<script>
	$(document).ready(myInitFunction());
	</script>

If you are using PHP:

		print <<<EOF
	<script>
	jQuery(document).ready(function() {
		// PUT INITIALIZATION HERE
	});
	</script>
	EOF;

If you are using Perl:

	print <<EOF;
	<script>
	jQuery(document).ready(function() {
		// PUT INITIALIZATION HERE
	});
	</script>
	EOF
What this info useful to you? You can donate to say thanks

Add a comment

Sign in to add a comment
Copyright © 2008-2012, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.
Advertisements: