是否可以修改下面的代码,使每个 < li class=" "> 都有一个类,其中包含第一个 span 标签中的文本?
$("#tabs-2").one("click", function(){
var x = $("#people span:first").text();
$("#drinks li").addClass(x);
});
<ul id="people">
<li id="singer">
<span class="0">1</span>
<span class="1">jane doe</span>
<span class="2">F</span>
</li>
<li id="singer">
<span class="0">2</span>
<span class="1">john doe</span>
<span class="2">m</span>
</li>
</ul>