jQuery die() remove event handler

Introduction

Remove the event handler changeSize().

View in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js">
</script>//from   w  ww.j  a va2  s .c  o  m
<script>
function changeSize(){
  $(this).animate({fontSize: "+=3px"});
}

function changeSpacing(){
  $(this).animate({letterSpacing: "+=2px"});
}

$(document).ready(function(){
  $("p").live("click", changeSize);
  $("p").live("click", changeSpacing);
  $("button").click(function(){
    $("p").die("click", changeSize);
  });
});
</script>
</head>
<body>

<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<p>Click any p element to increase size and letterspacing.</p>

<button>test</button><br><br>

</body>
</html>



PreviousNext

Related