Interface ZeptoCollection

Index

Methods

Methods

public add(selector: string, context?: any): ZeptoCollection

Modify the current collection by adding the results of performing the CSS selector on the whole document, or, if context is given, just inside context elements.

Parameters

  • selector: string
  • context?: any optional

Returns

ZeptoCollection

Self object.

public addClass(name: string): ZeptoCollection

Add class name to each of the elements in the collection. Multiple class names can be given in a space-separated string.

Parameters

  • name: string

Returns

ZeptoCollection

Self object.

public after(content: string): ZeptoCollection

Add content to the DOM after each elements in the collection. The content can be an HTML string, a DOM node or an array of nodes.

Parameters

  • content: string

Returns

ZeptoCollection

Self object.

public after(content: HTMLElement): ZeptoCollection

Parameters

  • content: HTMLElement

Returns

ZeptoCollection

public after(content: Array<HTMLElement>): ZeptoCollection

see

ZeptoCollection.after

Parameters

  • content: Array<HTMLElement>

Returns

ZeptoCollection

public after(content: ZeptoCollection): ZeptoCollection

see

ZeptoCollection.after

Parameters

Returns

ZeptoCollection

public animate(properties: any, duration?: number, easing?: string, complete?: () => void): ZeptoCollection

Smoothly transition CSS properties of elements in the current collection.

note

If the duration is 0 or $.fx.off is true (default in a browser that doesn’t support CSS transitions), animations will not be executed; instead the target values will take effect instantly. Similarly, when the target CSS properties match the current state of the element, there will be no animation and the complete function won’t be called. If the first argument is a string instead of object, it is taken as a CSS keyframe animation name.

note

Zepto exclusively uses CSS transitions for effects and animation. jQuery easings are not supported. jQuery's syntax for relative changes ("=+10px") is not supported. See the spec for a list of animatable properties (http://www.w3.org/TR/css3-transitions/#animatable-properties-). Browser support may vary, so be sure to test in all browsers you want to support.

Parameters

  • properties: any

    object that holds CSS values to animate to; or CSS keyframe animation name. Zepto also supports the following CSS transform porperties: translate(X|Y|Z|3d) rotate(X|Y|Z|3d) scale(X|Y|Z) matrix(3d) perspective skew(X|Y)

  • duration?: number optional

    (default 400): duration in milliseconds, or a string: fast (200 ms) slow (600 ms) any custom property of $.fx.speeds

  • easing?: string optional

    (default linear): specifies the type of animation easing to use, one of: ease linear ease-in ease-out ease-in-out cubic-bezier(x1, y1, x2, y2)

  • complete?: () => void optional

    Callback function when the animation has completed.

Returns

ZeptoCollection

Self object.

public animate(properties: any, options: ZeptoAnimateSettings): ZeptoCollection

see

ZeptoCollection.animate

Parameters

Returns

ZeptoCollection

public append(content: string): ZeptoCollection

Append content to the DOM inside each individual element in the collection. The content can be an HTML string, a DOM node or an array of nodes.

Parameters

  • content: string

Returns

ZeptoCollection

Self object.

public append(content: HTMLElement): ZeptoCollection

see

ZeptoCollection.append

Parameters

  • content: HTMLElement

Returns

ZeptoCollection

public append(content: Array<HTMLElement>): ZeptoCollection

see

ZeptoCollection.append

Parameters

  • content: Array<HTMLElement>

Returns

ZeptoCollection

public append(content: ZeptoCollection): ZeptoCollection

see

ZeptoCollection.append

Parameters

Returns

ZeptoCollection

public appendTo(target: string): ZeptoCollection

Append elements from the current collection to the target element. This is like append, but with reversed operands.

Parameters

  • target: string

Returns

ZeptoCollection

Self object.

public appendTo(target: HTMLElement): ZeptoCollection

see

ZeptoCollection.appendTo

Parameters

  • target: HTMLElement

Returns

ZeptoCollection

public appendTo(target: Array<HTMLElement>): ZeptoCollection

see

ZeptoCollection.appendTo

Parameters

  • target: Array<HTMLElement>

Returns

ZeptoCollection

public attr(name: string): string

Read or set DOM attributes. When no value is given, reads specified attribute from the first element in the collection. When value is given, sets the attribute to that value on each element in the collection. When value is null, the attribute is removed (like with removeAttr). Multiple attributes can be set by passing an object with name-value pairs. To read DOM properties such as checked or selected, use prop.

Parameters

  • name: string

Returns

string

public attr(name: string, value: any): ZeptoCollection

see

ZeptoCollection.attr

Parameters

  • name: string
  • value: any

Returns

ZeptoCollection

public attr(name: string, fn: (index: number, oldValue: any) => void): ZeptoCollection

see

ZeptoCollection.attr

Parameters

  • name: string
  • fn: (index: number, oldValue: any) => void

Returns

ZeptoCollection

public attr(object: any): ZeptoCollection

see

ZeptoCollection.attr

Parameters

  • object: any

Returns

ZeptoCollection

public before(content: string): ZeptoCollection

Add content to the DOM before each element in the collection. The content can be an HTML string, a DOM node or an array of nodes.

Parameters

  • content: string

Returns

ZeptoCollection

Self object.

public before(content: HTMLElement): ZeptoCollection

see

ZeptoCollection.before

Parameters

  • content: HTMLElement

Returns

ZeptoCollection

public before(content: Array<HTMLElement>): ZeptoCollection

see

ZeptoCollection.before

Parameters

  • content: Array<HTMLElement>

Returns

ZeptoCollection

public before(content: ZeptoCollection): ZeptoCollection

see

ZeptoCollection.before

Parameters

Returns

ZeptoCollection

public bind(type: string, fn: (e: Event) => void): ZeptoCollection

Attach an event handler to elements.

deprecated

use ZeptoCollection.on instead.

Parameters

  • type: string
  • fn: (e: Event) => void

Returns

ZeptoCollection

public children(selector?: string): ZeptoCollection

Get immediate children of each element in the current collection. If selector is given, filter the results to only include ones matching the CSS selector.

Parameters

  • selector?: string optional

Returns

ZeptoCollection

Children elements.

public clone(): ZeptoCollection

Duplicate all elements in the collection via deep clone. (!) This method doesn't have an option for copying data and event handlers over to the new elements, as it has in jQuery.

Returns

ZeptoCollection

Clone of the self object.

public closest(selector: string, context?: any): ZeptoCollection

Traverse upwards from the current element to find the first element that matches the selector. If context node is given, consider only elements that are its descendants. This method is similar to parents(selector), but it only returns the first ancestor matched. If a Zepto collection or element is given, the resulting element will have to match one of the given elements instead of a selector.

Parameters

  • selector: string
  • context?: any optional

Returns

ZeptoCollection

Closest element from the selector and context.

public concat(nodes?: Array<any>): ZeptoCollection

Modify the collection by adding elements to it. If any of the arguments is an array, its elements are merged into the current collection. (!) This is a Zepto-provided method that is not part of the jQuery API.

Parameters

  • nodes?: Array<any> optional

Returns

ZeptoCollection

Self object.

public contents(): ZeptoCollection

Get the children of each element in the collection, including text and comment nodes.

Returns

ZeptoCollection

Children including text and comment nodes.

public css(property: string): any

Read or set CSS properties on DOM elements. When no value is given, returns the CSS property from the first element in the collection. When a value is given, sets the property to that value on each element of the collection. Multiple properties can be set by passing an object to the method. When a value for a property is blank (empty string, null, or undefined), that property is removed. When a unitless number value is given, “px” is appended to it for properties that require units.

Parameters

  • property: string

Returns

any

public css(property: string, value: any): ZeptoCollection

see

ZeptoCollection.css

Parameters

  • property: string
  • value: any

Returns

ZeptoCollection

public css(properties: any): ZeptoCollection

see

ZeptoCollection.css

Parameters

  • properties: any

Returns

ZeptoCollection

public data(name: string): any

Read or write data-* DOM attributes. Behaves like attr, but prepends data- to the attribute name. When reading attribute values, the following conversions apply: “true”, “false”, and “null” are converted to corresponding types; number values are converted to actual numeric types; JSON values are parsed, if it’s valid JSON; everything else is returned as string. (!) Zepto's basic implementation of data() only stores strings. To store arbitrary objects, include the optional "data" module in your custom build of Zepto.

Parameters

  • name: string

Returns

any

public data(name: string, value: any): ZeptoCollection

see

ZeptoCollection.data

Parameters

  • name: string
  • value: any

Returns

ZeptoCollection

public delegate(selector: string, type: string, fn: (e: Event) => void): ZeptoCollection

Attach an event handler that is only triggered when the event originated from a node that matches a selector.

depcreated

use ZeptoCollection.on instead.

Parameters

  • selector: string
  • type: string
  • fn: (e: Event) => void

Returns

ZeptoCollection

public die(type: string, fn: (e: Event) => void): ZeptoCollection

Detach event handler added by live.

deprecated

use ZeptoCollection.off instead.

Parameters

  • type: string
  • fn: (e: Event) => void

Returns

ZeptoCollection

public die(types: any): ZeptoCollection

see

ZeptoCollection.die

deprecated

use ZeptoCollection.off instead.

Parameters

  • types: any

Returns

ZeptoCollection

public each(fn: (index: number, item: any) => boolean): ZeptoCollection

Iterate through every element of the collection. Inside the iterator function, this keyword refers to the current item (also passed as the second argument to the function). If the iterator function returns false, iteration stops.

Parameters

  • fn: (index: number, item: any) => boolean

Returns

ZeptoCollection

Self object.

public empty(): ZeptoCollection

Clear DOM contents of each element in the collection.

Returns

ZeptoCollection

Self object.

public eq(index: number): ZeptoCollection

Get the item at position specified by index from the current collection.

Parameters

  • index: number

Returns

ZeptoCollection

Item specified by index in this collection.

public filter(selector: string): ZeptoCollection

Filter the collection to contain only items that match the CSS selector. If a function is given, return only elements for which the function returns a truthy value. Inside the function, the this keyword refers to the current element. For the opposite, see not.

Parameters

  • selector: string

Returns

ZeptoCollection

Filtered collection.

public filter(fn: (index: number) => boolean): ZeptoCollection

see

ZeptoCollection.filter

Parameters

  • fn: (index: number) => boolean

Returns

ZeptoCollection

public find(selector: string): ZeptoCollection

Find elements that match CSS selector executed in scope of nodes in the current collection. If a Zepto collection or element is given, filter those elements down to only ones that are descendants of element in the current collection.

Parameters

  • selector: string

Returns

ZeptoCollection

Found items.

public find(collection: ZeptoCollection): ZeptoCollection

see

ZeptoCollection.find

Parameters

Returns

ZeptoCollection

public find(element: Element): ZeptoCollection

see

ZeptoCollection.find

Parameters

  • element: Element

Returns

ZeptoCollection

public first(): ZeptoCollection

Get the first element of the current collection.

Returns

ZeptoCollection

First element in the current collection.

public forEach(fn: (item: any, index: number, array: any[]) => void): ZeptoCollection

Iterate through every element of the collection. Similar to each, but the arguments for the iterator functions are different, and returning false from the iterator won’t stop the iteration. (!) This is a Zepto-provided method that is not part of the jQuery API.

Parameters

  • fn: (item: any, index: number, array: any[]) => void

Returns

ZeptoCollection

public get(): Array<HTMLElement>

Get all elements or a single element from the current collection. When no index is given, returns all elements in an ordinary array. When index is specified, return only the element at that position. This is different than eq in the way that the returned node is not wrapped in a Zepto collection.

Returns

Array<HTMLElement>

public get(index: number): HTMLElement

see

ZeptoCollection.get

Parameters

  • index: number

Returns

HTMLElement

public has(selector: string): ZeptoCollection

Filter the current collection to include only elements that have any number of descendants that match a selector, or that contain a specific DOM node.

Parameters

  • selector: string

Returns

ZeptoCollection

public has(node: HTMLElement): ZeptoCollection

see

ZeptoCollection.has

Parameters

  • node: HTMLElement

Returns

ZeptoCollection

public hasClass(name: string): boolean

Check if any elements in the collection have the specified class.

Parameters

  • name: string

Returns

boolean

public height(): number

Get the height of the first element in the collection; or set the height of all elements in the collection.

Returns

number

public height(value: number): ZeptoCollection

see

ZeptoCollection.height

Parameters

  • value: number

Returns

ZeptoCollection

public height(fn: (index: number, oldHeight: number) => void): ZeptoCollection

see

ZeptoCollection.height

Parameters

  • fn: (index: number, oldHeight: number) => void

Returns

ZeptoCollection

public hide(): ZeptoCollection

Hide elements in this collection by setting their display CSS property to none.

Returns

ZeptoCollection

public html(): string

Get or set HTML contents of elements in the collection. When no content given, returns innerHTML of the first element. When content is given, use it to replace contents of each element. Content can be any of the types described in append.

Returns

string

public html(content: string): ZeptoCollection

see

ZeptoCollection.html

Parameters

  • content: string

Returns

ZeptoCollection

public html(content: HTMLElement): ZeptoCollection

see

ZeptoCollection.html

Parameters

  • content: HTMLElement

Returns

ZeptoCollection

public html(content: Array<HTMLElement>): ZeptoCollection

see

ZeptoCollection.html

Parameters

  • content: Array<HTMLElement>

Returns

ZeptoCollection

public html(fn: (index: number, oldHtml: string) => void): ZeptoCollection

see

ZeptoCollection.html

Parameters

  • fn: (index: number, oldHtml: string) => void

Returns

ZeptoCollection

public index(element?: string): number

Get the position of an element. When no element is given, returns position of the current element among its siblings. When an element is given, returns its position in the current collection. Returns -1 if not found.

Parameters

  • element?: string optional

Returns

number

public index(element?: HTMLElement): number

see

ZeptoCollection.index

Parameters

  • element?: HTMLElement optional

Returns

number

public index(element?: any): number

see

ZeptoCollection.index

Parameters

  • element?: any optional

Returns

number

public indexOf(element: string, fromIndex?: number): number

Get the position of an element in the current collection. If fromIndex number is given, search only from that position onwards. Returns the 0-based position when found and -1 if not found. Use of index is recommended over this method. (!) This is a Zepto-provided method that is not part of the jQuery API.

see

ZeptoCollection.index

Parameters

  • element: string
  • fromIndex?: number optional

Returns

number

public indexOf(element: HTMLElement, fromIndex?: number): number

see

ZeptoCollection.indexOf

Parameters

  • element: HTMLElement
  • fromIndex?: number optional

Returns

number

public indexOf(element: any, fromIndex?: number): number

see

ZeptoCollection.indexOf

Parameters

  • element: any
  • fromIndex?: number optional

Returns

number

public insertAfter(target: string): ZeptoCollection

Insert elements from the current collection after the target element in the DOM. This is like after, but with reversed operands.

Parameters

  • target: string

Returns

ZeptoCollection

public insertAfter(target: HTMLElement): ZeptoCollection

see

ZeptoCollection.insertAfter

Parameters

  • target: HTMLElement

Returns

ZeptoCollection

public insertBefore(target: string): ZeptoCollection

Insert elements from the current collection before each of the target elements in the DOM. This is like before, but with reversed operands.

Parameters

  • target: string

Returns

ZeptoCollection

public insertBefore(target: HTMLElement): ZeptoCollection

see

ZeptoCollection.insertBefore

Parameters

  • target: HTMLElement

Returns

ZeptoCollection

public is(selector?: string): boolean

Check if the first element of the current collection matches the CSS selector. For basic support of jQuery’s non-standard pseudo-selectors such as :visible, include the optional “selector” module. (!) jQuery CSS extensions are not supported. The optional "selector" module only provides limited support for few of the most used ones.

Parameters

  • selector?: string optional

Returns

boolean

public last(): ZeptoCollection

Get the last element of the current collection.

Returns

ZeptoCollection

public live(type: string, fn: (e: Event) => void): ZeptoCollection

Like delegate where the selector is taken from the current collection.

deprepcated

use ZeptoCollection.on instead.

Parameters

  • type: string
  • fn: (e: Event) => void

Returns

ZeptoCollection

public load(url: string, fn?: (data: any, status: string, xhr: XMLHttpRequest) => void): ZeptoCollection

Set the html contents of the current collection to the result of a GET Ajax call to the given URL. Optionally, a CSS selector can be specified in the URL, like so, to use only the HTML content matching the selector for updating the collection: $('#some_element').load('/foo.html #bar') If no CSS selector is given, the complete response text is used instead. Note that any JavaScript blocks found are only executed in case no selector is given.

example
$('#some_element').load('/foo.html #bar')

Parameters

  • url: string

    URL to send the HTTP GET request to.

  • fn?: (data: any, status: string, xhr: XMLHttpRequest) => void optional

    Callback function when the HTTP GET request is completed.

Returns

ZeptoCollection

Self object.

public map(fn: (index: number, item: any) => any): ZeptoCollection

Iterate through all elements and collect the return values of the iterator function. Inside the iterator function, this keyword refers to the current item (also passed as the second argument to the function). Returns a collection of results of iterator function, with null and undefined values filtered out.

Parameters

  • fn: (index: number, item: any) => any

Returns

ZeptoCollection

public next(selector?: string): ZeptoCollection

Get the next sibling—optinally filtered by selector—of each element in the collection.

Parameters

  • selector?: string optional

Returns

ZeptoCollection

public not(selector: string): ZeptoCollection

Filter the current collection to get a new collection of elements that don’t match the CSS selector. If another collection is given instead of selector, return only elements not present in it. If a function is given, return only elements for which the function returns a falsy value. Inside the function, the this keyword refers to the current element. For the opposite, see filter.

Parameters

  • selector: string

Returns

ZeptoCollection

public not(collection: ZeptoCollection): ZeptoCollection

see

ZeptoCollection.not

Parameters

Returns

ZeptoCollection

public not(fn: (index: number) => boolean): ZeptoCollection

see

ZeptoCollection.not

Parameters

  • fn: (index: number) => boolean

Returns

ZeptoCollection

public off(type: string, selector: string, fn: (e: Event) => boolean): ZeptoCollection

Detach event handlers added with on. To detach a specific event handler, the same function must be passed that was used for on(). Otherwise, just calling this method with an event type with detach all handlers of that type. When called without arguments, it detaches all event handlers registered on current elements.

Parameters

  • type: string
  • selector: string
  • fn: (e: Event) => boolean

Returns

ZeptoCollection

public off(type: string, fn: (e: Event) => boolean): ZeptoCollection

see

ZeptoCollection.off

Parameters

  • type: string
  • fn: (e: Event) => boolean

Returns

ZeptoCollection

public off(type: string, selector?: string): ZeptoCollection

see

ZeptoCollection.off

Parameters

  • type: string
  • selector?: string optional

Returns

ZeptoCollection

public off(): ZeptoCollection

see

ZeptoCollection.off

Returns

ZeptoCollection

public off(events: ZeptoEventHandlers, selector?: string): ZeptoCollection

see

ZeptoCollection.off

Parameters

Returns

ZeptoCollection

public offset(): ZeptoCoordinates

Get position of the element in the document. Returns an object with properties: top, left, width and height. When given an object with properties left and top, use those values to position each element in the collection relative to the document.

Returns

ZeptoCoordinates

public offset(coordinates: ZeptoCoordinates): ZeptoCollection

see

ZeptoCollection.offset

Parameters

Returns

ZeptoCollection

public offset(fn: (index: number, oldOffset: number) => void): ZeptoCollection

see

ZeptoCollection.offset

Parameters

  • fn: (index: number, oldOffset: number) => void

Returns

ZeptoCollection

public offsetParent(): ZeptoCollection

Find the first ancestor element that is positioned, meaning its CSS position value is “relative”, “absolute” or “fixed”.

Returns

ZeptoCollection

public on(type: string, selector: string, fn: (e: Event) => boolean): ZeptoCollection

Add event handlers to the elements in collection. Multiple event types can be passed in a space-separated string, or as an object where event types are keys and handlers are values. If a CSS selector is given, the handler function will only be called when an event originates from an element that matches the selector. Event handlers are executed in the context of the element to which the handler is attached, or the matching element in case a selector is provided. When an event handler returns false, preventDefault() is called for the current event, preventing the default browser action such as following links.

Parameters

  • type: string
  • selector: string
  • fn: (e: Event) => boolean

Returns

ZeptoCollection

public on(type: string, fn: (e: Event) => boolean): ZeptoCollection

see

ZeptoCollection.on

Parameters

  • type: string
  • fn: (e: Event) => boolean

Returns

ZeptoCollection

public on(events: ZeptoEventHandlers, selector?: string): ZeptoCollection

see

ZeptoCollection.on

Parameters

Returns

ZeptoCollection

public one(type: string, fn: (e: Event) => void): ZeptoCollection

Adds an event handler that removes itself the first time it runs, ensuring that the handler only fires once.

Parameters

  • type: string
  • fn: (e: Event) => void

Returns

ZeptoCollection

public one(events: ZeptoEventHandlers): ZeptoCollection

see

ZeptoCollection.one

Parameters

Returns

ZeptoCollection

public parent(selector?: string): ZeptoCollection

Get immediate parents of each element in the collection. If CSS selector is given, filter results to include only ones matching the selector.

Parameters

  • selector?: string optional

Returns

ZeptoCollection

public parents(selector?: string): ZeptoCollection

Get all ancestors of each element in the collection. If CSS selector is given, filter results to include only ones matching the selector. To get only immediate parents, use parent. To only get the first ancestor that matches the selector, use closest.

Parameters

  • selector?: string optional

Returns

ZeptoCollection

public pluck(property: string): Array<string>

Get values from a named property of each element in the collection, with null and undefined values filtered out. (!) This is a Zepto-provided method that is not part of the jQuery API.

Parameters

  • property: string

Returns

Array<string>

public position(): ZeptoPosition

Get the position of the first element in the collection, relative to the offsetParent. This information is useful when absolutely positioning an element to appear aligned with another. Returns an object with properties: top, left.

Returns

ZeptoPosition

public prepend(content: string): ZeptoCollection

Prepend content to the DOM inside each element in the collection. The content can be an HTML string, a DOM node or an array of nodes.

Parameters

  • content: string

Returns

ZeptoCollection

public prepend(content: HTMLElement): ZeptoCollection

see

ZeptoCollection.prepend

Parameters

  • content: HTMLElement

Returns

ZeptoCollection

public prepend(content: Array<HTMLElement>): ZeptoCollection

see

ZeptoCollection.prepend

Parameters

  • content: Array<HTMLElement>

Returns

ZeptoCollection

public prepend(content: ZeptoCollection): ZeptoCollection

see

ZeptoCollection.prepend

Parameters

Returns

ZeptoCollection

public prependTo(content: string): ZeptoCollection

Prepend elements of the current collection inside each of the target elements. This is like prepend, only with reversed operands.

Parameters

  • content: string

Returns

ZeptoCollection

public prependTo(content: HTMLElement): ZeptoCollection

see

ZeptoCollection.prependTo

Parameters

  • content: HTMLElement

Returns

ZeptoCollection

public prependTo(content: Array<HTMLElement>): ZeptoCollection

see

ZeptoCollection.prependTo

Parameters

  • content: Array<HTMLElement>

Returns

ZeptoCollection

public prev(selector?: string): ZeptoCollection

Get the previous sibling—optionally filtered by selector—of each element in the collection.

Parameters

  • selector?: string optional

Returns

ZeptoCollection

public prop(name: string): any

Read or set properties of DOM elements. This should be preferred over attr in case of reading values of properties that change with user interaction over time, such as checked and selected.

Parameters

  • name: string

Returns

any

public prop(name: string, value: any): ZeptoCollection

see

ZeptoCollection.Prop

Parameters

  • name: string
  • value: any

Returns

ZeptoCollection

public prop(name: string, fn: (index: number, oldValue: any) => void): ZeptoCollection

see

ZeptoCollection.Prop

Parameters

  • name: string
  • fn: (index: number, oldValue: any) => void

Returns

ZeptoCollection

public push(elements?: Array<any>): ZeptoCollection

Add elements to the end of the current collection. (!) This is a Zepto-provided method that is not part of the jQuery API.

Parameters

  • elements?: Array<any> optional

Returns

ZeptoCollection

public ready(fn: ($: ZeptoStatic) => void): ZeptoCollection

Attach an event handler for the “DOMContentLoaded” event that fires when the DOM on the page is ready. It’s recommended to use the $() function instead of this method.

Parameters

  • fn: ($: ZeptoStatic) => void

Returns

ZeptoCollection

public reduce(fn: (memo: any, item: any, index: number, array: any[], initial: any) => any): any

Identical to Array.reduce that iterates over current collection. (!) This is a Zepto-provided method that is not part of the jQuery API.

Parameters

  • fn: (memo: any, item: any, index: number, array: any[], initial: any) => any

Returns

any

public remove(): ZeptoCollection

Remove elements in the current collection from their parent nodes, effectively detaching them from the DOM.

Returns

ZeptoCollection

public removeAttr(name: string): ZeptoCollection

Remove the specified attribute from all elements in the collection.

Parameters

  • name: string

Returns

ZeptoCollection

public removeClass(name?: string): ZeptoCollection

Remove the specified class name from all elements in the collection. When the class name isn’t given, remove all class names. Multiple class names can be given in a space-separated string.

Parameters

  • name?: string optional

Returns

ZeptoCollection

public removeClass(fn: (index: number, oldClassName: string) => void): ZeptoCollection

see

ZeptoCollection.removeClass

Parameters

  • fn: (index: number, oldClassName: string) => void

Returns

ZeptoCollection

public replaceWith(content: string): ZeptoCollection

Replace each element in the collection—both its contents and the element itself—with the new content. Content can be of any type described in before.

Parameters

  • content: string

Returns

ZeptoCollection

public replaceWith(content: HTMLElement): ZeptoCollection

see

ZeptoCollection.replacewith

Parameters

  • content: HTMLElement

Returns

ZeptoCollection

public replaceWith(content: Array<HTMLElement>): ZeptoCollection

see

ZeptoCollection.replacewith

Parameters

  • content: Array<HTMLElement>

Returns

ZeptoCollection

public scrollTop(): number

Gets the value of how many pixels were scrolled so far on window or scrollable element on the page.

Returns

number

public serialize(): string

Serialize form values to an URL-encoded string for use in Ajax post requests.

Returns

string

Seralized form values in URL-encoded string.

public serializeArray(): Array<any>

Serialize form into an array of objects with name and value properties. Disabled form controls, buttons, and unchecked radio buttons/checkboxes are skipped. The result doesn’t include data from file inputs.

Returns

Array<any>

Array with name value pairs from the Form.

public show(): ZeptoCollection

Restore the default value for the “display” property of each element in the array, effectively showing them if they were hidden with hide.

Returns

ZeptoCollection

public siblings(selector?: string): ZeptoCollection

Get all sibling nodes of each element in the collection. If CSS selector is specified, filter the results to contain only elements that match the selector.

Parameters

  • selector?: string optional

Returns

ZeptoCollection

public size(): number

Get the number of elements in this collection.

Returns

number

public slice(start?: number, end?: number): ZeptoCollection[]

Extract the subset of this array, starting at start index. If end is specified, extract up to but not including end index.

Parameters

  • start?: number optional
  • end?: number optional

Returns

ZeptoCollection[]

public submit(): ZeptoCollection

Trigger or attach a handler for the submit event. When no function given, trigger the “submit” event on the current form and have it perform its submit action unless preventDefault() was called for the event. When a function is given, this simply attaches it as a handler for the “submit” event on current elements.

Returns

ZeptoCollection

Self object.

public submit(fn: (e: any) => void): ZeptoCollection

see

ZeptoCollection.submit

Parameters

  • fn: (e: any) => void

    Handler for the 'submit' event on current elements.

Returns

ZeptoCollection

Self object.

public text(): string

Get or set the text content of elements in the collection. When no content is given, returns the text content of the first element in the collection. When content is given, uses it to replace the text contents of each element in the collection. This is similar to html, with the exception it can’t be used for getting or setting HTML.

Returns

string

public text(content: string): ZeptoCollection

see

ZeptoCollection.text

Parameters

  • content: string

Returns

ZeptoCollection

public toggle(setting?: boolean): ZeptoCollection

Toggle between showing and hiding each of the elements, based on whether the first element is visible or not. If setting is present, this method behaves like show if setting is truthy or hide otherwise.

Parameters

  • setting?: boolean optional

Returns

ZeptoCollection

public toggleClass(names: string, setting?: boolean): ZeptoCollection

Toggle given class names (space-separated) in each element in the collection. The class name is removed if present on an element; otherwise it’s added. If setting is present, this method behaves like addClass if setting is truthy or removeClass otherwise.

Parameters

  • names: string
  • setting?: boolean optional

Returns

ZeptoCollection

public toggleClass(fn: (index: number, oldClassNames: string) => void, setting?: boolean): ZeptoCollection

see

ZeptoCollection.toggleClass

Parameters

  • fn: (index: number, oldClassNames: string) => void
  • setting?: boolean optional

Returns

ZeptoCollection

public trigger(event: string, data?: Array<any>): ZeptoCollection

Trigger the specified event on elements of the collection. Event can either be a string type, or a full event object obtained with $.Event. If a data array is given, it is passed as additional arguments to event handlers. (!) Zepto only supports triggering events on DOM elements.

Parameters

  • event: string
  • data?: Array<any> optional

Returns

ZeptoCollection

public triggerHandler(event: string, data?: Array<any>): ZeptoCollection

Like trigger, but triggers only event handlers on current elements and doesn’t bubble.

Parameters

  • event: string
  • data?: Array<any> optional

Returns

ZeptoCollection

public unbind(type: string, fn: (e: Event) => boolean): ZeptoCollection

Detach event handler added with bind.

deprecated

use ZeptoCollection.off instead.

Parameters

  • type: string
  • fn: (e: Event) => boolean

Returns

ZeptoCollection

public undelegate(selector: string, type: string, fn: (e: Event) => boolean): ZeptoCollection

Detach event handler added with delegate.

deprecated

use ZeptoCollection.off instead.

Parameters

  • selector: string
  • type: string
  • fn: (e: Event) => boolean

Returns

ZeptoCollection

public unwrap(): ZeptoCollection

Remove immediate parent nodes of each element in the collection and put their children in their place. Basically, this method removes one level of ancestry while keeping current elements in the DOM.

Returns

ZeptoCollection

public val(): string

Get or set the value of form controls. When no value is given, return the value of the first element. For