my code is not working. I'm creating a variable then add event listener to it
btnColor=document.getElementById("first");
btnColor.addEventListener('click', changeBtnColor);
then I create a function that change the btn text color to red, if it's bg color is transparent
let changeBtnColor = (btnColor) => {
if (btnColor.style.backgroundColor == "trasnsparent") btnColor.style.color = "red";
}
and html code
<button type="button" class="first_text" id="first" onclick="changeBtnColor()">text</button>
You are saying this function needs to have
btnColorpassed in.In the inline
onclick="changeBtnColor()"you do not pass in the button reference.In the addEventListener
btnColoris the event object.Next issue is
trasnsparentis nottransparentSo with addEventListener you want to use currentTarget