0

Whenever my page loads, I try to remove a class from an element, but it still stays there.

I've tried using .removeclass() and remove() and getElementById() and removeChild().

var elem = document.getElementById("#logo");
elem.parentNode.removeChild(elem);
<a class="logo" href="/brand/logo.svg"></a>

The class is still being displayed after the change.

Rob Kwasowski
  • 2,690
  • 3
  • 13
  • 32

1 Answers1

1

You were trying to access the element by the id #logo. You don't include the # when using getElementById, and simply use logo. Also you were trying to remove the element, not the class. You have to use ELEMENT.classList.remove("CLASS_NAME");

var elem = document.getElementById("logo");
elem.parentNode.classList.remove("logo");
<a class="logo" href="/brand/logo.svg"></a>
Rob Kwasowski
  • 2,690
  • 3
  • 13
  • 32