jQuery bind() with additional data

Description

jQuery bind() with additional data

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  w  w  w  . j  av a2  s .c  o m*/
<script>
function handlerName(e){
  document.getElementById("demo").innerHTML = e.data.msg;
}

$(document).ready(function(){
  $("p").bind("click", {msg: "You just clicked me!"}, handlerName)
});
</script>
</head>
<body>

<p id="demo"></p>
<p>Click me!</p>

</body>
</html>



PreviousNext

Related