title: How to pass parameters into onclick function parameters into dynamically created buttons?
body: <p>My javascript reads text from a file and creates button dynamically base on the button creation below. The problem I am facing is it is not able to call the function on click. I've tried removing the parameters to call it and it works however I can't seem to get it to work with passing of parameters. Can someone help me with it?</p>
  
  <p>JS:</p>
  
  <pre><code>function toggleVisibility(type){
      alert(type);
  }
  </code></pre>
  
  <p>Button creation:</p>
  
  <pre><code>var button='&lt;button type="button" class="btn btn-block btn-inverse active" data-toggle="button tooltip" title="Click this to enable/disable viewing of '+this+'" onclick="toggleVisibility('+"'"+this+"'"+')"&gt;'+word+'&lt;/button&gt;';
  </code></pre>