title: Passing parameters to Anonymous function inside click event
body: <pre><code>var div_raw_id = 'acf-download-link';
  var div_id = '#' + div_raw_id; 
  var chapter_index = 1;
  var chapter = 'chapter-' + chapter_index;
  
  $('button[name=addnewchapter]').click(function(chapter, div_id ,div_raw_id){
      $(div_id).append('&lt;div class="acf-input-wrap"&gt;&lt;input id="' + div_raw_id +'" class="text" name="fields[field_55951fb44c1d6][' + chapter + '][]" value="" placeholder="" type="text"&gt;&lt;span class="remove_btn"&gt;&lt;/span&gt;&lt;/div&gt;');
      return false;
  });
  </code></pre>
  
  <p>The problem is  I cannot pass <code>div_id</code>, <code>chapter_index</code>, <code>chapter</code> as a parameter to the anonymous function inside the click event. I used the debugger and the debugger represents them as undefined values even though they are defined in above code. It seems there is a variable scope problem, however, I cannot figure out any other way to pass the defined variables as a parameter to the anonymous function inside the click event.</p>