I'm trying to get class name of the component in html. I have code like this:
<div class="dropdown-content"><a class="label" onclick="getComponentId(this)" href="#">Open terminal</p></div>
And this is my code snippet:
function getComponentId(el) {
var componentId = el.id;
var className = document.getElementsByClassName(el)
alert(className)
concatenateCredentials(credentials,componentId)
}
<div class="dropdown-content"><a class="label" onclick="getComponentId(this)" href="#">Open terminal</p></div>
I want to fetch class name "label". Above solution didn't work.
el.classNameshould be sufficient