Home > Blockchain >  How does getElementsByName work in Go/WebAssembly?
How does getElementsByName work in Go/WebAssembly?

Time:11-10

I am using Go and WebAssembly to do DOM manipulation. If I have something like this:

jsDoc := js.Global().Get("document")
getradio := jsDoc.Call("getElementsByName", "myradiobuttons")

What type is getradio? how do I find the radio button that was checked?

CodePudding user response:

Call will return a Value type. The getElementByName function in javascript should return a NodeList. So presumably you can do getradio.Call("item", 0), getradio.Call("item", 1), ect. to get your individual options, and then check if the checked property is true: getradio.Call("item", 0).Get("checked").

  • Related