Wee allows many methods to be chained to selectors by omitting the first argument of the method. This often makes code more readable and permits multiple methods to be executed on the same selection.


In this example, the target is faded out to full transparency.

    opacity: 0
}, {
    duration: 600



The reverse method simply reverses the order of the selection results.



Convert a Wee selection to a simple array



In this example, the selector is the element to which the event is bound.

$('.element').on('click', function() {
    // Click logic

Here the event is being triggered on the selector.



To register a new chainable method follow the pattern below.

Wee.$chain('setId', function(id) {
    this.attr('id', id);

    return this;

Alternatively you can register methods in a jQuery-compatible syntax.

$.fn.setId = function(id) {'id', id);

    return this;

To execute the method use the following.


Be sure to return this at the end of your method if the function’s purpose is not to return another value. This ensures the chain can continue.


All the core and DOM methods prefixed with $ are shortcut when chaining is enabled. Just remove the method’s dollar sign and replace Wee with $.


$.unique([1, 2, 2, 3]);


The view chain method updated the content of a DOM element given a data object.

<div class="element">
    <span class="{{ className }}">{{ content }}</span>
    className: 'dynamic-class',
    content: 'Span contents'