0

The HTML as follows:

screenshot

What I know:

  • TAG name is random ;
  • id is random, also class;
  • The common attribute is that they all have classname attr.

How should I remove them just use js?

Crystal
  • 101
  • 1
  • 1
  • 5
  • 2
    Does this answer your question? [Find an element in DOM based on an attribute value](https://stackoverflow.com/questions/2694640/find-an-element-in-dom-based-on-an-attribute-value) – Bryan Dellinger May 10 '21 at 01:36
  • 1
    It looks like you are violating lots of HTML rules for custom elements. Read more here: https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements – code May 10 '21 at 01:47

1 Answers1

2

You can use .removeAttribute in the HTMLelement, here is an example:

function removeClassname() {
  const elements = document.querySelectorAll('[classname]')

  elements.forEach((element) => {
    element.removeAttribute('classname')
  })
}
[classname] {
  background-color: red;
}
<div classname="abc">asdasd</div>
<button classname="abc">asdasd</button>
<p classname="abc">asdasd</p>

<button onclick="removeClassname()">Remove classname</button>
Daniel Rodríguez Meza
  • 1,167
  • 1
  • 8
  • 17