///
Hello
") //=> the new P element $("", { text: "Hello", id: "greeting", css: { color: 'darkblue' } }) Zepto(function ($) { alert('Ready to Zepto!'); }) $.camelCase('hello-there') //=> "helloThere" $.camelCase('helloThere') //=> "helloThere" $.each(['a', 'b', 'c'], function (index, item): boolean { console.log('item %d is: %s', index, item); return true; }); var hash = { name: 'zepto.js', size: 'micro' } $.each(hash, function (key, value) { console.log('%s: %s', key, value); return true; }); var target = { one: 'patridge' }, source = { two: 'turtle doves' } $.extend(target, source); $.fn.empty = function () { return this.each(function () { this.innerHTML = '' }); } $.isPlainObject({}); // => true $.isPlainObject(new Object); // => true $.isPlainObject(new Date); // => false $.isPlainObject(window); // => false $('form label').after('A note below the label
'); $('ul').append('Emphasis mine.
').insertAfter('blockquote'); $('See the following table:
').insertBefore('table'); $('li').last(); elements.map(function () { return $(this).text() }).get().join(', '); $('dl dt').next(); //=> the DD elements $('h1').parents(); //=> [Content
'); $.Event('mylib:change', { bubbles: false }); var obj = { name: 'Zepto' }; var handler = function (e: Event) { console.log("hello from + ", this.name); return true; }; // ensures that the handler will be executed in the context of `obj`: $(document).on('click', <(e: Event) => boolean>$.proxy(handler, obj)); elem = $('#content'); // observe all clicks inside #content: elem.on('click', function (e) { return true; }); // observe clicks inside navigation links in #content elem.on('click', 'nav a', function (e) { return true; }); // all clicks inside links in the document $(document).on('click', 'a', function (e) { return true; }); // add a handler for a custom event $(document).on( 'mylib:change', <(e: Event) => boolean>function (e, from, to) { console.log('change on %o with data %s, %s', e.target, from, to); return true; } ) // trigger the custom event $(document.body).trigger('mylib:change', ['one', 'two']); $(document).on('ajaxBeforeSend', <(e: Event) => boolean>function (e, xhr, options) { // This gets fired for every Ajax request performed on the page. // The xhr object and $.ajax() options are available for editing. // Return false to cancel this request. return true; }); $.ajax({ type: 'GET', url: '/projects', // data to be added to query string: data: { name: 'Zepto.js' }, // type of data we are expecting in return: dataType: 'json', timeout: 300, context: $('body'), success: function (data) { // Supposing this JSON payload was received: // {"project": {"id": 42, "html": "