Use the on() method to attach a click event handler to all <p> elements. - Javascript jQuery

Javascript examples for jQuery:Mouse Event

Description

Use the on() method to attach a click event handler to all <p> elements.

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").on("click", function(){
        $(this).hide();//from w  w w  .j a v  a 2s  .c  o m
    });
});
</script>
</head>
<body>

<p>If you click on me, I will disappear.</p>

</body>
</html>

Related Tutorials