You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
function init() {
var drink = document.getElementById("coffee");
drink.innerHTML = "I love tea.";
drink.setAttribute("color", "red");
}
window.onload = init;
I love coffee.
This is my code.
I have selected the element with the id "coffee" and assigned it to the variable "drink".
I changed its content with the "innerHTML" property.
And, now, I want to set a "color" attribute to the element .
What's wrong with my code ? Why is the color not changing ??
The text was updated successfully, but these errors were encountered:
function init() {
var drink = document.getElementById("coffee");
drink.innerHTML = "I love tea.";
drink.setAttribute("color", "red");
}
I love coffee.
This is my code.
I have selected the element with the id "coffee" and assigned it to the variable "drink".
I changed its content with the "innerHTML" property.
And, now, I want to set a "color" attribute to the element .
What's wrong with my code ? Why is the color not changing ??
The text was updated successfully, but these errors were encountered: