简体   繁体   中英

How to tell which element number i'm clicking on?

I have a table with 6 elements.. How can I know which one in the dom have I clicked on? Meaning.. I want to know that I click on tag #3 as it is the 3rd (or 4th if you count 0) in the dom..

I was thinking of just assigning an ID to each tag and that id would contain a number designating which is being clicked.. but there must be a cleaner way...

hope this is clear enough - sorry i'm tired.

只是想出了.. jQuery具有.index()功能。

我很确定这就是您要寻找的东西: http : //api.jquery.com/index/#example-0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM