dom

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package dom is wraps HTMLElement. It also includes Bootstrap (4).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendChild

func AppendChild(child interface{})

AppendChild appends child to document.

func RemoveChild

func RemoveChild(child *Element)

RemoveChild removes child form document.

Types

type Element

type Element struct {
	*js.EventTarget
}

Element represents a HTML element.

func CreateElement

func CreateElement(tag string) *Element

CreateElement returns a HTML element.

func ElementOf

func ElementOf(v js.Value) *Element

ElementOf returns a HTML element.

func S

func S(selector string) *Element

S returns one element in document with query selector condition.

func (*Element) AddClass

func (e *Element) AddClass(names ...string) *Element

AddClass add class to element.

func (*Element) Append

func (e *Element) Append(child ...interface{}) *Element

Append appends child to element.

func (*Element) Attr

func (e *Element) Attr(name string) string

Attr returns attribute value.

func (*Element) Call

func (e *Element) Call(name string, args ...interface{}) js.Value

Call invokes element method.

func (*Element) Clone

func (e *Element) Clone() *Element

Clone clones the element. https://developer.mozilla.org/en-US/docs/Web/API/Node/cloneNode.

func (*Element) Data

func (e *Element) Data(key, value string) *Element

Data adds "data-*" attribute.

func (*Element) Empty

func (e *Element) Empty() *Element

Empty cleans children.

func (*Element) Free

func (e *Element) Free()

Free disposes this element.

func (*Element) HTML

func (e *Element) HTML() string

HTML return inner html of element.

func (*Element) HasClass

func (e *Element) HasClass(name string) bool

HasClass returns boolean indicates whether or not element has the class.

func (*Element) On

func (e *Element) On(event string, fn func(*Element, *js.Event)) *Element

On add listener for some event.

func (*Element) OnChange

func (e *Element) OnChange(fn func(*Element, *js.Event)) *Element

OnChange adds callback function when element value changed.

func (*Element) OnClick

func (e *Element) OnClick(fn func(*Element, *js.Event)) *Element

OnClick adds callback function when clicking element.

func (*Element) Prepend

func (e *Element) Prepend(child interface{}) *Element

Prepend inserts new child as first child.

func (*Element) Prop

func (e *Element) Prop(name string) js.Value

Prop returns property of element.

func (*Element) RemoveAttr

func (e *Element) RemoveAttr(name string) *Element

RemoveAttr removes soem attribute.

func (*Element) RemoveChild

func (e *Element) RemoveChild(elm *Element) *Element

RemoveChild removes child element.

func (*Element) RemoveClass

func (e *Element) RemoveClass(names ...string) *Element

RemoveClass remove class from element.

func (*Element) ReplaceClass

func (e *Element) ReplaceClass(oldName, newName string) *Element

ReplaceClass replace some class of element with new one.

func (*Element) S

func (e *Element) S(selector string) *Element

S returns child by quering selector condition.

func (*Element) SS

func (e *Element) SS(selector string) ElementList

SS returns children by query selector condition.

func (*Element) SetAttr

func (e *Element) SetAttr(name, value string) *Element

SetAttr sets attribute.

func (*Element) SetHTML

func (e *Element) SetHTML(html string) *Element

SetHTML set inner html of element.

func (*Element) SetProp

func (e *Element) SetProp(name string, val interface{}) *Element

SetProp sets property.

func (*Element) SetText

func (e *Element) SetText(text string) *Element

SetText set inner text of element.

func (*Element) SetVal

func (e *Element) SetVal(val interface{}) *Element

SetVal set value to input, select, or textarea element.

func (*Element) String

func (e *Element) String() string

func (*Element) TagName

func (e *Element) TagName() string

TagName returns tag name (all lower case) of element.

func (*Element) Text

func (e *Element) Text() string

Text returns inner text of element.

func (*Element) ToggleClass

func (e *Element) ToggleClass(name string) *Element

ToggleClass toggle some class of element.

func (*Element) Truthy

func (e *Element) Truthy() bool

Truthy returns javascript truthy value.

func (*Element) Val

func (e *Element) Val() string

Val returns value of form input, select or textarea element.

type ElementList

type ElementList []*Element

ElementList is a collection of elements.

func ElementListOf

func ElementListOf(v js.Value) ElementList

ElementListOf returns a element list.

func SS

func SS(selector string) ElementList

SS returns elements in document with query selector condition.

func (ElementList) AddClass

func (nl ElementList) AddClass(names ...string) ElementList

AddClass adds class to all elements.

func (ElementList) Append

func (nl ElementList) Append(x ...*Element) ElementList

Append add a new element.

func (ElementList) AppendList

func (nl ElementList) AppendList(other ElementList) ElementList

AppendList appends other list.

func (ElementList) Attr

func (nl ElementList) Attr(name string) []string

Attr returns some attribute values.

func (ElementList) Foreach

func (nl ElementList) Foreach(fn func(idx int, v *Element))

Foreach apply function on each element.

func (ElementList) HasClass

func (nl ElementList) HasClass(name string) ElementList

HasClass returns elements which has specific class.

func (ElementList) Length

func (nl ElementList) Length() int

Length returns the size of list.

func (ElementList) Prop

func (nl ElementList) Prop(name string) []js.Value

Prop returns some property values.

func (ElementList) RemoveClass

func (nl ElementList) RemoveClass(names ...string) ElementList

RemoveClass remove some class from all elements.

func (ElementList) ReplaceClass

func (nl ElementList) ReplaceClass(oldName, newName string) ElementList

ReplaceClass replace some class with new one on all elements.

func (ElementList) SetAttr

func (nl ElementList) SetAttr(name, value string) ElementList

SetAttr sets attribute to all elements.

func (ElementList) SetProp

func (nl ElementList) SetProp(name string, flag bool) ElementList

SetProp sets property to all elements.

func (ElementList) SetVal

func (nl ElementList) SetVal(val interface{}) ElementList

SetVal set value to all elements.

func (ElementList) TagName

func (nl ElementList) TagName() []string

TagName returns all tag names.

func (ElementList) ToggleClass

func (nl ElementList) ToggleClass(name string) ElementList

ToggleClass toggles some class on all elements.

func (ElementList) Val

func (nl ElementList) Val() []string

Val returns all values.

Directories

Path Synopsis
bs
Package bs is a Bootstrap toolkit.
Package bs is a Bootstrap toolkit.
alert
Package alert wraps Bootstrap Alert component
Package alert wraps Bootstrap Alert component
badge
Package badge wraps Bootstrap Badge component
Package badge wraps Bootstrap Badge component
button
Package button wraps Bootstrap Button component.
Package button wraps Bootstrap Button component.
card
Package card wraps Bootstrap Card component.
Package card wraps Bootstrap Card component.
list
Package list wraps Bootstrap List Group component.
Package list wraps Bootstrap List Group component.
modal
Package modal wraps Bootstrap Modal component.
Package modal wraps Bootstrap Modal component.
progress
Package progress wraps Bootstrap Progress component.
Package progress wraps Bootstrap Progress component.
spinner
Package spinner wraps Bootstrap spinner component.
Package spinner wraps Bootstrap spinner component.
table
Package table wraps Bootstrap default Table Content.
Package table wraps Bootstrap default Table Content.

Jump to

Keyboard shortcuts

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