element.style.removeProperty("background-color") throwing error Uncaught ReferenceError: cannot assign to function call

Viewed 20
let rating_3 = document.getElementsByClassName("user-rating__rating-number-3")[0];

Uncaught ReferenceError: cannot assign to function call in below function @ "HERE"

Why is this error thrown and how to handle this situation ?

I'm new to JS, coming from Java background; it's pretty hard to debug these kind of issues.

rating_3.addEventListener("click", () => {

    rating_3.style.removeProperty("background-color") = "";  <== HERE

    rating_3.classList.add("user-rating__rating-number--orange");

    removeClassFromElements(rating_3);

    submit.disabled = false;
});
1 Answers

Why are you assigning it to an empty string

rating_3.style.removeProperty("background-color")

just remove the property

Related