tiny-elementready.js - Element Ready delay for tinyJS

tiny-elementready.js calls a function, after at least one element of an selection is available.

Download

tiny-elementready.js [215b] - tiny-elementready-min.js.gz [135b]

Hint

The t.er-function requires only tiny.js. Other scripts are not necessary.

Usage

t.er has two arguments, at first the Selector, which is tried every 45ms on if it returns at least one element, second the callback to be executed with said selection as scope (this).

Example

t.er('#copyright', function() { 
    if (this[0] && this[0].nodeName && this[0]===document.getElementById('copyright')) { 
        t('#test').h('<span class="passed">passed</span>'); 
    }
});

--element ready test: failed