-1

I my code I need to redefine certain event function inside another event function. I've been trying the same way as in the code below, but after pressing "Click me" after pressing "Change" I want to have just one alert "kukkuu kukkuu" instead of two alerts "kukkuu" and "kukkuu kukkuu". So how to make $("p1").click(function() to redefine $("p").click(function() instead of adding another $("p").click(function() ?

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("p").click(function(){
    alert("kukkuu")
  });
   $("p1").click(function(){
   alert("changing")
    $("p").click(function(){
    alert("kukkuu kukkuu")
  });
  });
    
});
</script>
</head>
<body>

<p>If you click on me, I will answer.</p>
<p>Click me </p>
<p1>Change</p1>

</body>
</html>
Jaana
  • 237
  • 2
  • 11

0 Answers0