I spent a lot of time trying to get rid of "RangeError: Maximum call stack size exceeded."
error.
Here is the solution I came up with.
Just assign a new value to yourContent
variable and you are ready to go.
Hope someone will find this helpful.
var targetElement = document.getElementById("google_translate_element");
var yourContent = "Your text or <br /> HTML element"
targetElement.addEventListener("DOMNodeInserted", () => {
$(".goog-te-menu-value span:first").each(function (i, obj) {
if (obj.childNodes[0] && obj.childNodes[0].textContent == "Select Language") {
$(obj).html(yourContent);
}
});
});
Also, if you want to add image instead of text, you will need to add the following css to clean up unnecessary borders:
.goog-te-menu-value span:nth-child(3),
.goog-te-menu-value span:nth-child(5),
.goog-te-gadget-icon,
.goog-te-banner-frame.skiptranslate {
display:none !important;
}
div#google_translate_element div.goog-te-gadget-simple {
border: none;
background-color: transparent;
}