In Jquery how do you find out the 'eq' of an element of what is being clicked?

前端 未结 4 1615
无人共我
无人共我 2021-02-05 01:49

When one of the divs inside \'uploadChoice\' is clicked, how can I ascertain which one is clicked? Can I return an \'eq\' value somehow?

 
4条回答
  •  温柔的废话
    2021-02-05 02:29

    You can add selectors as well, and pass "$(this)" as argument:

    $(document).on('click', 'button.testbutton', function () {
      
      var index = $('div.example > div.xyz').find('button.testbutton').index($(this));
    
    });

提交回复
热议问题