I have something that I would like to convert from jquery to js.
I am using js to create 12 li elements which when clicked gets the index number, in jquery I used the .index() function to achieve this,
var month = $(".calenderApp__calender__allMonths__month"),
startMonth;
$(month).on('click', function () {
startMonth = $(this).index() + 1;
});
How would I do this is vanilla js, I have gotten as far as
var month = document.querySelectorAll(".calenderApp__calender__allMonths__month"),
startMonth;
for (var i=0; i<month.length; i++) {
month[i].addEventListener("click", function () {
startMonth = this; //returns full html element, just need index number
});
}