Learn free online HTML5, javascript, and jquery Tutorials by Examples

Wednesday 5 November 2014

Create custom events and trigger in jQuery

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>custom events in jquery</title>
<script src="js/jquery.js" ></script>
</head>
<body>
    <div class="me">custom events in jquery</div>
</body>
</html>
<script type="text/javascript">
    $(document).ready(function() {
        $('.me').bind('satish',function(){
            console.log('you click on body');
        });
        $('.me').click(function() {
            $(this).trigger('satish');
        });
    });
</script>

No comments:

Post a Comment