dom

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2025 License: MIT Imports: 2 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddClass

func AddClass(elem string, class string)

----------------------------------------------------------------------------

Adds a CSS class to the specified element

func AddElementTo

func AddElementTo(target, elem HTMLElement)

----------------------------------------------------------------------------

Adds the specified element to the target element

func AddEventListener

func AddEventListener(elem string, event string, fn func())

----------------------------------------------------------------------------

Wraps a Go function and sets it as the callback for the specified event on the target element

func AddNewStyleElement added in v0.0.3

func AddNewStyleElement(style string)

----------------------------------------------------------------------------

Creates a new style element for the page

func AddToBody

func AddToBody(element HTMLElement)

----------------------------------------------------------------------------

Adds the specified element directly to the document body.

func GetString

func GetString(elem string, value string) string

----------------------------------------------------------------------------

Gets the specified value from the target element as a string

func Hide

func Hide(elem string)

----------------------------------------------------------------------------

Toggles display to "none" on the specified element

func Log

func Log(message ...string)

----------------------------------------------------------------------------

Log calls JavaScript console.log in the browser.

func RemoveAllChildElementsFrom added in v0.0.4

func RemoveAllChildElementsFrom(target HTMLElement)

----------------------------------------------------------------------------

Removes all the child elements from this element

func RemoveClass

func RemoveClass(elem string, class string)

----------------------------------------------------------------------------

Removes the specified CSS class from the target element

func SetFocus

func SetFocus(elem string)

----------------------------------------------------------------------------

Calls "focus()" on the target element

func SetValue

func SetValue(elem string, key string, value string)

----------------------------------------------------------------------------

Sets the specified key to the given value on the target element

func Show

func Show(elem string)

----------------------------------------------------------------------------

Toggles display to "block" on the specified element

func ShowAlert

func ShowAlert(msg string)

----------------------------------------------------------------------------

Types

type HTMLElement

type HTMLElement = js.Value

----------------------------------------------------------------------------

func CreateButton

func CreateButton(text string) HTMLElement

----------------------------------------------------------------------------

Creates a "button" element

func CreateDiv

func CreateDiv() HTMLElement

----------------------------------------------------------------------------

Creates and returns a new "div" element

func CreateElement

func CreateElement(element string) HTMLElement

----------------------------------------------------------------------------

Creates the specified element type

func CreateImg

func CreateImg(src string) HTMLElement

----------------------------------------------------------------------------

func CreateParagraph

func CreateParagraph() HTMLElement

----------------------------------------------------------------------------

Creates and returns a new "p" element

func CreateParagraphWithText

func CreateParagraphWithText(text string) HTMLElement

----------------------------------------------------------------------------

Creates and returns a new "p" with the innerText set to the given text value

func GetElementById

func GetElementById(elem string) HTMLElement

----------------------------------------------------------------------------

Attempt to find an element with the given Id

func GetElementValue

func GetElementValue(elem string, value string) HTMLElement

----------------------------------------------------------------------------

Gets the specified value from the target element

func ReplaceClasses

func ReplaceClasses(element HTMLElement, classes ...string) HTMLElement

----------------------------------------------------------------------------

Replaces all the classes for the element with the provided list

func WrapElementWithNewDiv

func WrapElementWithNewDiv(element HTMLElement, divClasses ...string) HTMLElement

----------------------------------------------------------------------------

Wraps an existing element in a new div of the type specified

Jump to

Keyboard shortcuts

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