有人请帮我解决这个音云 api

Someone please help me with this soundcloud api

这是我的 html 和 js 文件:

window.onload = function(){
 SC.initialize({
  client_id: "f5311a935daa5ecf6440f92183e77df1"
 });
 
 var menuLinks = document.getElementsByClassName("genre");
 for (var i=0; i < menuLinks.length; i++){
  var menuLink = menuLinks[i];
  menuLink.onclick = function(e){
   e.preventDefault();
   playSounds(menuLink.innerHTML);
  };
 };
};

function playSounds(genre){
 SC.get('/tracks', {genres: genre}, function(tracks){
  var random = Math.floor(Math.random()*49);
  SC.oEmbed(tracks[random].uri, {autoplay: false}, document.getElementById("content"));
 });
};
<html>
<head>
 <title>SoundCloud API</title>
 <script type="text/javascript" src="script.js"></script>
 <script src="//connect.soundcloud.com/sdk-2.0.0.js"></script>
</head>

<body>
<ul>
<li><a href="#" class="genre">electronic</a></li>
<li><a href="#" class="genre">trap</a></li>
<li><a href="#" class="genre">dubstep</a></li>
</ul>

<div id="content"></div>
</body>
</html>

所以基本上当我点击任何 link 时,它应该搜索那个特定的流派,但它只会搜索 dubstep,无论我点击哪个 link。有人可以帮忙吗?

替换

playSounds(menuLink.innerHTML);

playSounds(this.innerHTML);

它不起作用的原因是,当您单击 link 时,它会查找 menuLink,它现在等于循环中定义的最后一个(<a>dubstep</a> ).