Suppose that throughout the dom I have several links with the same class, how can I know the index that this link is when clicked.
<a href="#seccion" class="section-modchooser-link"></a> // Este seria el indice 0
<a href="#ejemplo" class="section-modchooser-link"></a> // Este seria el indice 1
<a href="#otro-ejemplo" class="section-modchooser-link"></a> // Este seria el indice 2
$('a.section-modchooser-link').on('click',function(e){
e.preventDefault()
var clicked = $(this)
})
What I'm looking for: if I click on link 1, know that this link within the dom is number 1
The method
$.index()
returns the index of the element in jQuery.