jquery get index of element in array code example
Example 1: js in_array
var a = [1, 2, 3];
a.includes(2); // true
a.includes(4); // false
Example 2: jquery find index of this
$(document).ready(function() {
$("#example div").click(function() {
var index = $("#example div").index(this);
$("#example_index").html("Index " + index + " was clicked");
});
});
Example 3: jquery get element by index
$('ul li').eq(index).css({'background-color':'#343434'});