I have a single javascript function i want to call when a page has loaded. I haven't used jQuery before but have found the $(document).ready option. Can I use this to run my javascript and if so do where do I put my code. Would rather not put in a module unless it's necessary... Many thanks Gary
Gary, for quick and simple in your module, use: <code> drupal_add_js(' $(document).ready(function() { alert("This ran after the DOM was loaded."); }); ', 'inline'); </code> ...replacing the alert with whatever it is you need to do. -Seth garyl wrote:
I have a single javascript function i want to call when a page has loaded.
I haven't used jQuery before but have found the $(document).ready option. Can I use this to run my javascript and if so do where do I put my code. Would rather not put in a module unless it's necessary...
Many thanks Gary
-- [ Drupal support list | http://lists.drupal.org/ ]
participants (2)
-
garyl -
Seth Freach