title: Get the id of a link when clicked using Javascript
body: <p>I'm new to Javascript, and trying to design a form with elements that are created and deleted by clicks on links without submitting a form.</p>
  
  <p>The script depends on getting the unique id of a clicked button (css and <code>&lt;a&gt;</code> link), and calculating the id of the row containing the link, and then deleting the entire <code>&lt;tr&gt;</code> element.</p>
  
  <p>For this, I'm trying to get the id of a clicked link. The link and the elements it is embedded in, is itself generated by javascript on clicking another button.</p>
  
  <p>I tried the following:</p>
  
  <pre><code>var btnDel=document.createElement("a");
  btnDel.id="NS_D"+count;
  btnDel.className="btn btn-danger";
  btnDel.addEventListener('click', function() 
  {            
      alert(e.id);
  }, false);
  var btnText=document.createElement("span");
  btnText.className="btn-label";
  btnText.innerHTML="Delete";
  btnDel.appendChild(btnText);            
  td.appendChild(btnDel);     
  </code></pre>
  
  <p>Though the button is generated, I'm not getting an alert as expected. Where can I have gone wrong?</p>