Posted By

reverend on 04/01/11


Tagged

div element jquery execute


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

maltem


execute / do stuff when element is ready


 / Published in: jQuery
 

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

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

Originally seen here: http://www.codingforums.com/archive/index.php/t-144582.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>

Report this snippet  

You need to login to post a comment.