jQuery triggerHandler() trigger custom event

Description

jQuery triggerHandler() trigger custom event

View in separate window

<!DOCTYPE html>
<html>
<head>
<script 
 src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js">
</script>//from www. j  a va  2 s .co m
<script>
$(document).ready(function(){
  $("p").click(function(){
    $("p").on("myPara", function(event, param1, param2, param3){
      document.getElementById("demo").innerHTML = 
         param1 + "\n" + param2 + "\n" + param3;
    });
    $("p").triggerHandler("myPara", ['A', 'B', 'C']);
  });
});
</script>
</head>
<body>

<p id="demo"></p>
<p>Click to alert additional parameters.</p>

</body>
</html>



PreviousNext

Related