Get value of List Item with jQuery

后端 未结 5 971
后悔当初
后悔当初 2021-02-08 07:19

How to get value and index of list item onClick event with jQuery?
for example:

  • Item 1
  • Item 2&
5条回答
  •  鱼传尺愫
    2021-02-08 07:34

    $('#uItem li').click(function(){
     var $this = $(this);
     alert('Text ' + $this.text() + 'Index ' + $this.index());
    })
    

    Check working example at http://jsfiddle.net/yccyJ/1/

提交回复
热议问题