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

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

    You can get the contents of the div with

    $("#uploadChoice div").click(function(){
        var choice = $(this).html;
    }
    

    And then just do a switch statement or some nested ifs.

    Personally though, I'd add an ID to each of the divs and just check the ID of the clicked element.

提交回复
热议问题