jQuery one() handle click and double click event

Introduction

Click and double click any p element to increase its text size.

Event handlers will trigger once per element per event type (one click, and one dblclick).

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  .  ja  va2 s . com*/
<script>
$(document).ready(function(){
  $("p").one("click dblclick", function(){
    $(this).animate({fontSize: "+=2px"});
  });
});
</script>
</head>
<body>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<p>This is a paragraph.</p>
</body>
</html>



PreviousNext

Related