How to use jquery to add selected to the corresponding option? Option is selected by default based on the current date

<select name="year" id="year">
    <option value="2017" >2017</option>
    <option value="2018" >2018</option>
    <option value="2019" >2019</option>
</select>
var datetime = new Date();
datetime.setTime(time);
var year = datetime.getFullYear();
var y = document.getElementById("year").value;

now that I have the current year, how can I automatically add selected to the above option based on the current value?
to learn the vue, now to set up a separate page, to let jquery write, only contact yesterday, many of the writing can not, please teach me, thank you

Jun.20,2022

use val () method

$(function (){
    var datetime = new Date();
    var year = datetime.getFullYear();

    // id=yearselectjQuery
    var $year = $("-sharpyear");
    // selectval()inputselecttextarea
    $year.val(year);
});
Menu