title: creating '<a href onclick=function... with javascript I get error: Uncaught ReferenceError: popup is not defined
body: <p>I have puled data from server and created a list of thumbnails and some other data from twitch TV. </p>
  
  <p>I need to create popup tab with video stream in it.</p>
  
  <p>Therefore I have put thumbnail in anchor tag and called a <code>popup()</code> function onclick.  (I am planing to put parameters for playing video in that function.)
  Also I have created function for that <code>popup()</code> but no matter where I place it I get an Error in console when I click on thumbnail.</p>
  
  <pre><code>ERROR: Uncaught ReferenceError: popup is not defined
  </code></pre>
  
  <p>This is the JS code:</p>
  
  <pre><code>$(document).ready(function(){   
      $.getJSON( "https://api.twitch.tv/kraken/streams", function( data ) {
      var items = [];
      var videoHTML ='&lt;ul&gt;';
  
      //Popup Tab with streaming video
  
      $.each(data.streams, function(i, video){ 
          videoHTML += '&lt;li class="video-stream ' + video.channel.language + '"&gt;';
          videoHTML += '&lt;img class="user-logo" src="' + video.channel.profile_banner + '"&gt;';
          videoHTML += '&lt;p class="user-name"&gt;' + video.channel.display_name + '&lt;/p&gt;';
          videoHTML += '&lt;a href="#" onClick="popup()"&gt;';
          videoHTML += '&lt;img class="video-image" src="' + video.preview.medium + '"&gt;&lt;/a&gt;';
          videoHTML += '&lt;h1 class="game-name"&gt;' + video.game + '&lt;/h1&gt;&lt;br/&gt;';
          videoHTML += '&lt;i&gt;&lt;/i&gt;';
          videoHTML += '&lt;span class="views-number"&gt;' + video.viewers + '&lt;/span&gt;';
          videoHTML += '&lt;p class="short-date-format date' + i + '"&gt;' + video.created_at + '&lt;/p&gt;';
          videoHTML += '&lt;/li&gt;';
  
          var d = new Date(video.created_at);
          //var dateClass = 'date' + i;                 console.log(dateClass);
          //$(dateClass).html = d.toDateString();
  
      //console.log(video._id);
      //console.log(data.streams[i].game);
  
      //console.log(data.streams[i]._links.self);
      //console.log(data.streams[i].preview.medium);
      });
  
  videoHTML += '&lt;/ul&gt;';
  $('#placeholder').html(videoHTML);
  
      }); //getJson
  
      //popup tab
      function popup(){
      alert('wow');
      }           
  
  }); //end ready
  </code></pre>
  
  <p>Can You please help me with this becasue I can not find an answer on the internet?</p>
  
  <p>-How to get <code>popup()</code> function running?
  -How to implement parameter into this function? </p>
  
  <p>(Also, I have tried to write anchor in HTML and add function and then everything works fine but when I create HTML with JS then I have this problem.</p>
  
  <p>Thank You in front!</p>
  
  <p>Sincerely,</p>
  
  <p>Denis </p>