Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(function() {
- var $square = $('.square');
- // Register a custom event and bind an event handler on it
- $square.on('square.resize', function() {
- console.log('Square is resized!');
- });
- // Trigger that event when you change the square size
- function resizeSquare() {
- $square.width($square.width() + 10);
- $square.height($square.height() + 10);
- $square.trigger('square.resize');
- }
- // Anytime you resize the square, it will trigger 'square.resize' event
- // In this example, I am using setInverval() to resize the square, but you could
- // change it into any way you like
- setInterval(resizeSquare, 1000);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement