How to get the position of an specific li in a ul tag?

前端 未结 1 433
野性不改
野性不改 2021-01-24 10:47

I want to get number of one li that I hover on with jQuery. this is my code :

相关标签:
1条回答
  • 2021-01-24 11:22

    You can use this:

    var number = $(this).index() + 1;
    

    Demo here

    The .index() starts at 0 so I added +1 because you wanted to start counting from 1.

    0 讨论(0)
提交回复
热议问题