Created
December 1, 2013 11:53
-
-
Save RalfAlbert/7732687 to your computer and use it in GitHub Desktop.
Custom events with jQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>jQuery Testseite</h1> | |
<p id="test">Hello World!</p> | |
<p><a href="#" id="clickit">Click it!</a></p> | |
<script type="text/javascript"> | |
$(document).ready( | |
function() { | |
$('#test').bind( | |
'colorChange', | |
function() { | |
console.log('Color changed!'); | |
} | |
); | |
$('#clickit').click( | |
function(){ | |
$('#test').css('color', 'Red'); | |
$('#test').trigger('colorChange') | |
} | |
); | |
} | |
); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment