CodePen

HTML

            
              <html>
  <head>
    <title>example</title>
  </head>
  <body>
    
  </body>
</html>
            
          
!

CSS

            
              
            
          
!
? ?
? ?
Must be a valid URL.
+ add another resource
via CSS Lint

JS

            
              (function() {
  document.addEventListener('click', function(e) {
    if (e.target.tagName !== 'A') return;
    
    e.preventDefault();
    e.stopPropagation();
    
    alert(e.target.getAttribute('data-source-id'));
  });
  
  var name = 'somename',
      source_id = '1';
  
  var filelink = document.createElement('a');
  filelink.setAttribute('href', '#');
  filelink.setAttribute('data-source-id', source_id);
  filelink.appendChild(document.createTextNode(name));

  document.getElementsByTagName('body')[0].appendChild(filelink);
}());
            
          
!
Must be a valid URL.
+ add another resource
via JS Hint
Loading ..................