Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Custom events in jquery

    • 0
    • 1
    • 1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 232
    Comment on it

    When we think about the jquery then first thing comes in mind that is events so today we are going to discuss the custom events. Do you know about custom events? Its name has cleared the concept, means your own events. There are so many benefits of custom events. You can call the custom event using trigger function when require. It separates the code and make the code easily readable. Let's take an simple example.

    jQuery(function($){
    jQuery(document).on('userFeedback'{
        subject:'title goes here',
        function(e,param){
        $('.subject').html(e.data.subject);
        $('.mess').html(param);
        }
    
    }); 
    jQuery(document).trigger('userFeedback',["user message only"]);
    });  
    <div class="subject"></div>
    <div class="mess"></div>
    

    In above example we are simply showing user feedback and we can trigger the event any time according the our requirement. It is easy to use and easy to understand the code flow.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: