开发者

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

开发者 https://www.devze.com 2023-01-31 02:43 出处:网络
I have a table with 6elements.. 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 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开发者_高级运维.


just figured it out.. jquery has an .index() feature.


Im pretty sure that this is what you are looking for: http://api.jquery.com/index/#example-0

0

精彩评论

暂无评论...
验证码 换一张
取 消