toggleAttribute

fun toggleAttribute(qualifiedName: String, force: Boolean = definedExternally): Boolean(source)

The toggleAttribute() method of the present and adding it if it is not present) on the given element.

MDN Reference