dom

package
v0.0.0-...-88fbf3c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 4, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Rendered for js/wasm

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterFunc

func RegisterFunc(name string, fn CallbackFunc)

RegisterFunc registers a java script function

Types

type CallbackFunc

type CallbackFunc func(this js.Value, args []js.Value) interface{}

CallbackFunc defines the signature of a callback

type Element

type Element struct {
	js.Value
}

Element represents a dom element

func CreateElement

func CreateElement(name string) *Element

CreateElement calls into the dom to create a new element

func Document

func Document() *Element

Document returns the dom document node

func FromValue

func FromValue(val js.Value) *Element

FromValue returns an element from a js.Value

func GetElementByID

func GetElementByID(name string) *Element

GetElementByID calls into the dom to getElementById https://www.w3schools.com/jsref/met_document_getelementbyid.asp

func (*Element) AddEventListener

func (e *Element) AddEventListener(event string, listener CallbackFunc)

AddEventListener attaches an event listener to the current element

func (*Element) Append

func (e *Element) Append(e2 *Element) *Element

Append adds a child element to this element

func (*Element) Clone

func (e *Element) Clone() *Element

Clone makes a copy of the current element

func (*Element) GetElementByTagName

func (e *Element) GetElementByTagName(tag string) *Element

GetElementByTagName returns the first element with a matching tag name under the current element

func (*Element) GetElementsByTagName

func (e *Element) GetElementsByTagName(tag string) []*Element

GetElementsByTagName returns a slice of elements with the given tag name

func (*Element) GetInnerHTML

func (e *Element) GetInnerHTML() *Element

GetInnerHTML returns the inner html data

func (*Element) ParentElement

func (e *Element) ParentElement() *Element

ParentElement returns the parent element of the current element

func (*Element) RemoveAllEventListeners

func (e *Element) RemoveAllEventListeners() *Element

RemoveAllEventListeners removes all event listeners from the current element

func (*Element) ReplaceChild

func (e *Element) ReplaceChild(newChild *Element, oldChild *Element)

ReplaceChild replaces a child node based on the child node

func (*Element) WithID

func (e *Element) WithID(id string) *Element

WithID sets the id attribute of the element

func (*Element) WithInnerHTML

func (e *Element) WithInnerHTML(content interface{}) *Element

WithInnerHTML overwrites any text or sub nodes of this element

type Location

type Location struct {
	Href     string
	Host     string
	Hostname string
	Protocol string
	Pathname string
	Search   string
	Hash     string
}

Location represents the javascript location object https://www.w3docs.com/snippets/javascript/how-to-get-current-url-in-javascript.html

func ParseLocation

func ParseLocation() (*Location, error)

ParseLocation parses the javascript location object into a Location struct instance

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL