title: How to create dynamic a-tag onclick to call external function using javascript
body: <p>I'm working on laravel project with ajax request. I can have response from controller as below.</p>
  
  <pre><code>    success:function(response){
           var output = "";
           $.each(response, function(i, item) {
              var room = item.room;
              var route = `{{url('medicalroom/callque/${id}')}}`;                    
              output += `&lt;a onclick="confirmation(event)" href="${route}" '&gt;Room ${("00" + room).slice(-2)} &lt;/a&gt;`;
              })
           $('#roomlist').html(output);
       }
  
      function confirmation(e) {
          e.preventDefault();
          alert(route);
      });
  </code></pre>
  
  <p>I can add results to div <code>roomlist</code> but once do the <code>onclick</code> then not event fire. Any advise or guidance would be greatly appreciated, Thanks.</p>