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.
Thank you!
<span visible-language="en" id="myAttrID">...</span>
const myAttr = document.getElementById("myAttrID")
let getData = myAttr.getAttribute("visible-language");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.