In jQuery, you can do this:
$(this).data("index");
which will automatically access the data-index attribute using jQuery's .data() feature.
Or you can use this to read the attribute directly:
$(this).attr("data-index");
Since, you know there's only one element in the jQuery object, there's no reason to use the [0] complication. Though you don't need it here, if you ever want the first item out of a jQuery object and you want the result in a jQuery object, you can use .eq(0) as in $(this).eq(0).attr("data-index");, but since you already know there's only one element in $(this), there's no reason for it here.
Or, in plain JS, you can do this:
this.getAttribute("data-index");
Or, in modern browsers, you can do:
this.dataset.index
which uses the newer .dataset feature.
$(this).eq(0).attr("data-index")or$($(this)[0]).attr("data-index");$(this)[0].getAttribute("data-index");