In my script I need to check if my newly created object inherits from a specific class. Found out this:
Check if an element contains a class in JavaScript?
I have tried to implement like this:
class Testing {
}
let test = new Testing();
let elem = document.getElementById("result");
try {
elem.innerHTML = test.classList.contains("Testing");
} catch (e) {
elem.innerHTML = e;
}
<span id="result">...</span>
Unfortunately, it's not working. Please help me find a solution.