Get the value of the onclick attribute of a button: const nodeMap = document.getElementById("myButton"); let value = nodeMap.getNamedItem("onclick").value; Try it . writing document.forms["myForm"] will return the form with the name "myForm" from that collection. Javascript DOM HTML document forms Collection, Javascript DOM HTML document forms Collection get by index, Javascript DOM HTML document forms Collection get by items(index), Javascript DOM HTML document forms Collection iterate elements from first form, Javascript DOM HTML document forms Collection loop. an HTMLCollection. Hey, this just happened to a completed form, and is now happening in several forms. The forms read-only property of the Document interface returns an HTMLCollection listing all the <form> elements contained in the document. Frequently asked questions about MDN Plus. The namedItem() Method is used to return the element with having the specified ID, OR, name or content in an HTML element collection in the document.