JQuery Trigger click not triggering

  Kiến thức lập trình

I have a list of years and want to select the 1st element triggering a click but it’s not working as I expect. This code gets me to the element on which I want to trigger a click on but it does nothing and there are no errors in the console.

$("#years > span > a").eq(0).trigger("click");

I’ve put this line of code on the last line in my JavaScript file, so my understanding is that after everything is loaded, the click should be triggered.

Why isn’t this working as I expect?

LEAVE A COMMENT