Pass in data for event handler using delegate() - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:delegate

Description

Pass in data for event handler using delegate()

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(e){//from w  w w. j  a  va2  s.c om
    console.log(e.data.msg);
}
$(document).ready(function(){
    $("p").delegate({msg: "You just clicked me!"}, "click", handlerName)
});
</script>
</head>
<body>

<p>Click me!</p>

</body>
</html>

Related Tutorials