Pass data to event handler - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:on

Description

Pass data to event handler

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>
function handlerName(event) {/*from  w  w  w  .j a  v  a  2  s . c o  m*/
    console.log(event.data.msg);
}

$(document).ready(function(){
    $("p").on("click", {msg: "hi!"}, handlerName)
});
</script>
</head>
<body>

<p>Click me!</p>

</body>
</html>

Related Tutorials