I’ve got several span tags, with the same class. Every span has it’s unique id. Now I’d like to get the content and the id of the clicked span class.
I found out how I go about the id of the class, but I can’t seem to get the content between the <span></span> tags. I tried this.html(), this.html, this.text and this.tex() but I can’t get the text.
$(".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>
You could use
innnerHTML, and you missed);at last.