Trigger custom event with custom parameters - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:triggerHandler

Description

Trigger custom event with custom parameters

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("p").click(function(){
        $("p").on("myPara", function(event, param1, param2, param3){
        console.log(param1 + "\n" + param2 + "\n" + param3);
    });// w  w  w.ja va 2 s  . c o  m
    $("p").triggerHandler("myPara", ['Pass', 'Along', 'Parameters']);
    });
});
</script>
</head>
<body>

<p>Click to alert additional parameters.</p>

</body>
</html>

Related Tutorials