title: JavaScript Playlist Target Element
body: <p>I am working on a JavaScript driven audio player with a playlist. I have a problem when I try to add a click event to the elements I want to play. </p>
  
  <p>Apparently I am doing something wrong in the loop because the elements are displayed, yet not played. No errors in the console.</p>
  
  <p><strong><a href="http://jsfiddle.net/SimeriaIonut/jsw3hma4/" rel="nofollow">JSFIDDLE HERE</a></strong></p>
  
  <pre><code>//object
  obj = {
      songsrc: ["mariah_carey_all_i_want", "chris_rea_driving", "wham_last_christmas", "dean_martin_snow", "brenda_lee_rocking"],
      title: ["Mariah Carey", "Chris Rea", "Wham", "Dean Martin", "Brenda Lee"],
      songs: ["All I want for christmas is you", "Driving home for christmas", "Last christmas", "Let it snow", "Rocking around"],
      images: ["mariah_carey", "wham", "chris_rea", "dean_martin", "brenda_lee"]
  }
  
  // the &lt;ul&gt; in which the li elements I have lay
  mylist.addEventListener("click", changeTrack);
  
  // adding the songs to the playlist
  addTrack();
  function addTrack() {
      for(var i = obj.title.length-1; i &gt;= 0; i--) {
          li = document.createElement("li");
          li.className = "songs_wrap";
          li.innerHTML = "&lt;div class='songs_inner'&gt;" + "&lt;h4&gt;"+obj.title[i]+ "&lt;/h4&gt;&lt;p&gt;" + obj.songs[i] + "&lt;/p&gt;&lt;/div&gt;";
          mylist.appendChild(li);
      }
  }
  
  // trying to make them play when I click a song (a li element)
  function changeTrack(event) {
      var target = event.target;
      while (target != mylist) {
          if (target.nodeName == 'LI') 
          {
              for(var i = target; i &lt; obj.songsrc.length; i++)  // I guess this is wrong
              {   
                  obj.images.src = "images/" + obj.images[i] + ".jpg";
                  var title = playlist_status.innerHTML = obj.title[i];
                  var song = playlist_song.innerHTML = obj.songs[i];
                  audio.src = dir + obj.songsrc[i] + ext;
                  playbtn_icon.className = "icon-pause";
                  audio.play();
              }
          }
          target = target.parentNode
      }
  }
  </code></pre>