I am trying to change some can which depends in jQuery to pure JS and I was wondering how I can translate this one:
$("#mydiv .car span").text(myVariable);
What would the code above be in pure JS?
You can do it using document.querySelector() and textContent like this:
document.querySelector("#mydiv .car span").textContent = myVariable;
Or using innerText like this :
document.querySelector("#mydiv .car span").innerText = myVariable;
MDN Reference for document.querySelector()
Returns the first Element within the document that matches the specified selector, or group of selectors.
Which makes it similar to jQuery with the possibility of using this kind of selector.
document.querySelector("#mydiv .car span").textContent = myVariable;