Advertisement
Guest User

Untitled

a guest
Apr 27th, 2015
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. $(function() {
  2. var $square = $('.square');
  3.  
  4. // Register a custom event and bind an event handler on it
  5. $square.on('square.resize', function() {
  6. console.log('Square is resized!');
  7. });
  8.  
  9. // Trigger that event when you change the square size
  10. function resizeSquare() {
  11. $square.width($square.width() + 10);
  12. $square.height($square.height() + 10);
  13. $square.trigger('square.resize');
  14. }
  15.  
  16. // Anytime you resize the square, it will trigger 'square.resize' event
  17. // In this example, I am using setInverval() to resize the square, but you could
  18. // change it into any way you like
  19. setInterval(resizeSquare, 1000);
  20.  
  21. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement