I am trying to focus on a link with a given index using js dispatch event:
var link = document.querySelector(".navbar-nav > li:nth-child(" + index + ") > a");
var event = new Event("focus");
link.dispatchEvent(event);
The code above won't work whereas the jQuery version works OK:
$(".navbar-nav > li:nth-child(" + index + ") > a").focus();
I am testing in the latest Chrome. What is wrong with the JS version?