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

前端 未结 4 1621
无人共我
无人共我 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:42

    An easier alternative that does not require duplicating a selector is the following

    $('#uploadChoice div').click(function(event) {
      var index = $(this).prevAll().length;
    });
    

提交回复
热议问题