title: button click itself many times
body: <p>I want to make a button for editing a post and after first edit I want to be able to edit the post again and again by pressing the button and I achieved this by calling the function again ( function1 ). The problem is the program somehow remember every press(I think) and every time I edit a post(without refreshing page) the program call my function(function1) for every button press I've done before..I will show in pictures.</p>
  
  <p>Here are 3 pictures: [images]: (<a href="https://imgur.com/a/d8KTqSP" rel="nofollow noreferrer">https://imgur.com/a/d8KTqSP</a>).</p>
  
  <p>The first one is when I edit first time, the second one after second edit, and the third one is after I edited my post 2 more times,
  That notify show me when the function is called and those function chain from script is called how many times i press the Edit button..
  That's it..sry for long post, I hope someone can find the bug.</p>
  
  <p>I expect to edit a post how many times I want, without function1 running  for every press on Edit button I am making; I am begginer with JS, i used just for one week and now I am stuck.</p>
  
  <p>P.S i am using codeigniter php framework for backend</p>
  
  <pre><code>&lt;?php foreach ($exit as $a)
      { if( $a['endpoint_id'] === $id)
      { ?&gt;
      &lt;ul class=" list-group"&gt;
           &lt;li class="list-group-item col-md-12" style="display: inline;" id="urllist&lt;?php echo $a['id']?&gt;" &gt; 
              &lt;div id="showUrl&lt;?php echo $a['id'];?&gt;" style="display:block" data-myValue="&lt;?php echo $a['exit_url'];?&gt;"&gt;             
                  &lt;p id="urlText&lt;?php echo $a['id'];?&gt;" &gt; &lt;?php echo $a['exit_url']; echo PHP_EOL; ?&gt; &lt;/p&gt; 
               &lt;/div&gt;
              &lt;div style="margin-right:1px;" id="Div&lt;?php echo $a['id'];?&gt;" &gt;
                   &lt;input type="hidden" value=&lt;?php echo $a['id'] ?&gt; id='&lt;?php echo $a['id'];?&gt;'&gt;
                   &lt;button onclick="function1(&lt;?php echo $a['id']; ?&gt;); " class="btn btn-primary" id="btn&lt;?php echo $a['id']?&gt;" &gt;Edit&lt;/button&gt; 
                   &lt;button onclick="function2(&lt;?php echo $a['id']; ?&gt;)" class="btn btn-primary" &gt; Delete &lt;/button&gt; 
  
              &lt;/div&gt;
           &lt;/li&gt;
      &lt;/ul&gt;
  &lt;?php 
      }   
  } ?&gt;
  
  function function1(id) {
  
          //$("#btn"+id).prop("onclick",null); //removing onclick event for  avoiding the bug :'()
  
          if($("#update_url"+id).length) {
              $("#update_url"+id).show();
              $("#submit_update"+id).show();
          }
           else {
              $("#Div"+id).append($('&lt;input type="text"&gt;').attr('id',"update_url"+id).attr('value',$("#showUrl"+id).attr('data-myValue'))); //make input text
              $("#Div"+id).append($('&lt;input type="submit"&gt;').attr('value','Update').attr('id','submit_update'+id)); //make input submit and apend them      
           }
  
          $("#submit_update"+id).click(function() {
              update_url(id);
         });    
      }
  
  //sending updated url to controller(db)
  function update_url(id) {
      $(document).ready(function() {
      var deca =  $("#update_url"+id).val();
  
      $.ajax({
               type: "POST",
               url:  "&lt;?php echo base_url(); ?&gt;endpoint/update_url1",
               data: 'value1='+deca+'&amp;value2='+id,
              success: function(data){
                  $.notify("Update successfully","success");
                  $("#submit_update"+id).click(show_update_url(id));
                  $("#submit_update"+id).hide();
                  $("#update_url"+id).hide();
              }
          });
      });
      }
  
  //show updated exit url after edit press
  function show_update_url(id) {
          $(document).ready(function() {
              $.ajax(
              {
                  type: "GET",
                  url: "&lt;?php echo base_url();?&gt;endpoint/new_url/"+id,
                  success : function(text)
                  {
                      if($("#phehe"+id).length) {
                          $("#phehe"+id).hide();
                      }
  
                      //alert(text);
                      $("#Div"+id).prepend($('&lt;p&gt;'+text+'&lt;/p&gt;').attr('id','phehe'+id));
  
                  }
              });
          });
          $("#urlText"+id).css("display","none");
      }
  </code></pre>