The common method of starting jQuery is putting it in
$(document).ready(function() {
// put all jQuery stuff here
});
But what if I have a complicated site which uses basic jQuery in <head> and some custom functions that depend on the page type (e.g. if I have login page, fire some login ajax stuff).
So, how can I attach code to $(document).ready() or fire it later? Which JS syntax should I use?
Thanks for help!
My page structire is similar to this:
- Display static header using PHP’s
include() - Add content inside
<body></body> - Display the template footer
<?php
include_once('system/classes/class.display.php');
$d = new IFDisplay();
$d->display_header(array('subtitle' => 'Log In')); <-- Here it displays static
head tags. There is
document.ready in there.
I can't change it.
?>
<script type="text/javascript">
AND WHAT DO I NEED TO PUT HERE
</script>
<div>...</div>
<?php
$d->display_footer();
?>
If you aren’t worried about race conditions, you should be able to use this:
As many times as you like.