Skip to content

Latest commit

 

History

History
90 lines (68 loc) · 2.94 KB

Markup.md

File metadata and controls

90 lines (68 loc) · 2.94 KB

Markup

Kind: global class
Npmpackage:

new Markup()

This object contains utilities relateed to dom elements.
Import from ad-view

import { Markup } from 'ad-view'

Markup.get(selector, parent) ⇒ element | HTMLCollection

Used to select elements.

Kind: static method of Markup
Returns: element | HTMLCollection - One single element if the selector is an id. With class name or tag name, it returns an HTML collection ( similiar to an array ).

Param Type Description
selector string A string selector. It defaults to find the string as an id, or if the string starts with '#'. If starts with '.', it selects by class name. If wrapped with '<>', it selects by tag name.
parent element Optional parent element to get the element(s) from. Defaults to document.

Example

// get element by its id called 'myId'
Markup.get('myId')

// same as above
Markup.get('#myId')

// get element by CSS classname 'myClass'
Markup.get('.myClass')

// get elements by tag name 'head'
Markup.get('<head>')

Markup.removeChildren(_target)

Removes all the children elements of an element

Kind: static method of Markup

Param Type Description
_target element element to be targeted

Markup.applyToElements(arg)

Apply a method to multiple elements. Currently assuming the method accepts element as the first argument, and a second argument as the setting.

Kind: static method of Markup

Param Type Description
arg object See properties for more info:

Properties

Name Type Description
arg.scope object the scope of this
arg.method function the function to use
arg.element element | array the element(s) to apply the method to, can be a single element or an array
arg.methodArg string | number | array | object the argument to pass to the method function

Example

var myElements = Markup.get( '.centered-blocks' );
Markup.applyToElements({
	scope: Align,
	method: Align.set,
	elements: myElements,
	methodArg: { x: Align.CENTER }
})