How to use jQuery to get a unique id?

So I’m trying to build a tictactoe game with jQuery. I’ve watched a tutorial on how to do it with javascript. There is a function that grabs the unique id of an html element in javascript. How do you do something similar to that in jQuery. For instance, here is html:`
table class = “table”>

		<td id="s1"	class="square"></td>
		<td id="s2" class="square"></td>
		<td id="s3" class="square"></td>
		<td id="s4" class="square"></td>
		<td id="s5" class="square"></td>
		<td id="s6" class="square"></td>	
		<td id="s7" class="square"></td>
		<td id="s8" class="square"></td>
		<td id="s9" class="square"></td>	

Here is the jquery code i’m using:

	function getBox(numbers){
		var numbers = $('#s1, #s2, #s3, #s4, #s5, #s6, #s7, #s8, #s9')

		return numbers.text();

What I want the function to do is everytime you click on a td in the game, it retrieves the unique id such as "#s1, “s2”, etc.

Thanks for any help


I think this link will help you.

I don’t believe putting all these id’s into one single numbers will help you. You would want to identify each id to what to do when it is clicked.

Hope this helps.

Thanks…i’ll give it a try


For a sanity check, you can always use console.log(“Hey this works! I am id#1”) within a function and you monitor that in dev console so you will know it got triggered.