Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Custom events with jQuery
<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
You can’t perform that action at this time.