Reputation: 1861
I have a parser written in TypeScript, but there are important custom HTML attributes.
<span visible-language="en">...</span>
How can I read them? I can't just make the HTMLElement
as a type of any
and get it as an attribute because the attribute key contains a -
which isn't allowed in TypeScript / JavaScript Syntax.
I don't use any frameworks, just plain TypeScript.
Upvotes: 1
Views: 2406
Reputation: 194
<span visible-language="en" id="myAttrID">...</span>
const myAttr = document.getElementById("myAttrID")
let getData = myAttr.getAttribute("visible-language");
Upvotes: 3