Getting element values?
alvid-the-bot opened this issue · comments
How does one get element values with this package?
I tried calling myElement.GetAttribute("value")
, but that ended up returning an empty value, rather than the value of my input field.
Is this something that needs additional implementation? Happy to PR something if that's the case.
I think the problem is that the value
is not an HTML attribute, but a JS object field.
Try getting the original JS value and calling Get
on it:
myElement.JSRef().Get("value")
As an alternative, check how Input
element does this.
I'm assuming an issue was resolved. Feel free to reopen.
Trying to do the same thing but I think I missing something, any insight ?
input := dom.Doc.GetElementById("input")
btn := dom.Doc.GetElementById("btn")
btn.AddEventListener("click", func(_ dom.Event) {
dom.ConsoleLog(input.JSValue().Get("value"))
})
Can you provide an example ? Seems like the example you gave only create elements so they are already there as Inputs and Buttons.