I am trying to translate these few lines of jQuery based code into vanilla JS but I am struggling. Can someone please explain how to do it?
function googletranslate() {
$(".footer-toggle li, .select-lng li").on("click", function() {
var rel = $(this).children("a").attr("rel");
$(".goog-te-menu-frame:first").contents().find(".goog-te-menu2 .goog-te-menu2-item span:contains('" + rel + "')").get(0).click();
});
}
setTimeout(googletranslate, 1000);
I know how to do a click event with javascript but im having a hard time finding the element (Just started learning).
<a href="#" rel="Spanish" title="Spanish">Spanish</a>
Basically when the link is clicked, it feeds through rel value to the hidden google translate widget, and simulates a click on the desired language.
Can someone explain how please? Would it be easier to use a select box and get the value from that instead?
document.querySelectorand.querySelectorAllto use complex css selectors like jQuery