execute / do stuff when element is ready


/ Published in: jQuery
Save to your folder(s)

Execute function / action when an element has loaded or clicked.

Originally seen here: http://www.codingforums.com/archive/index.php/t-144582.html


Copy this code and paste it in your HTML
  1. <html>
  2. <head>
  3. <script type="text/javascript" src="jquery/jquery.js"></script>
  4. <script type="text/javascript">
  5.  
  6. $(document.getElementsByTagName('div')[0]).ready(function() {
  7. // do stuff when div is ready
  8. alert('loaded');
  9. });
  10. $(document.getElementById('mydiv')).click(function() {
  11. // do stuff when clicked
  12. alert('clicked');
  13. });
  14. </script>
  15. </head>
  16. <body>
  17. <div id="mydiv">My Div</div>
  18. </body>
  19. </html>

URL: http://www.codingforums.com/archive/index.php/t-144582.html

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.