我有几个span标签,具有相同的类。每个span人都有它唯一的 id。现在我想获取点击span类的内容和 id。
我发现了如何处理班级的 id,但我似乎无法获得<span></span>标签之间的内容。我试过this.html(), this.html,this.text但this.tex()我无法得到文本。
$(".row").click(function() {
alert(this.id);
alert(this.html);
}
HTML:
<div>
<span class="row" id="1">Username of user 1</span>
<span class="row" id="2">Username of user 2</span>
<div>