jQuery - get the index of a element with a certain class

前端 未结 2 1532
灰色年华
灰色年华 2020-12-16 09:30

I have a list like this one:

  • ....
  • ....
  • ....
  • ....
  • 2条回答
    •  离开以前
      2020-12-16 10:14

      With the .index() :

      $('li.active').index()
      

      Working example here:

      http://jsfiddle.net/EcZZL/

      Edit - added link to the api for .index() per Nick's advice

    提交回复
    热议问题