$(window).load(function () {
let max = new Date().getFullYear(),
min = max - 10
for (let i = max; i >= min; i--) {
let opt = new Option()
$(opt).html(i)
$(opt).val()
$('#type-year').append(opt)
}
})
const yearSelected = $('#type-year option:selected')
$("#year-value").html(yearSelected.text())
console.log(yearSelected.val())
I'm trying to set the values to numbers 0 - 10. For example, the value of 2020 should be 0, the value of 2019 should be 1, value of 2018 should be 2, and on.