Compatibility notes Collections are real Arrays, so native
.map()/
.slice() return plain arrays.
.val() on a checkbox returns a boolean. AJAX returns native Promises. Handlers receive native events. Full list:
migrating from jQuery and
comparisons .
Core & Selectors
Core & Selectors Everything starts with $(). A jsKjs set is a real Array subclass, so native methods (map, spread, for...of) work alongside the chainable API.
$()
$(selector [, context]) · $(element) · $(html) · $(fn)
The heart of the library. Accepts a CSS selector (optionally scoped to a context), a DOM node, window, a NodeList/array, an HTML string (creates elements), or a function (runs on DOM ready).
JavaScript Copy $ ( '.card' ) // CSS selector
$ ( 'li' , '#menu' ) // scoped to context
$ ( document.body) // wrap a node
$ ( '<div class="x">Hi</div>' ) // create elements
$ ( ( ) => console.log ( 'DOM ready' ) ) ;
See it live: Selectors & collections →
.each()
.each((index, element) => {}) → self
Iterate the set jQuery-style. Inside the callback, this is the current element.
JavaScript Copy $ ( '.item' ) .each ( function ( i, el) {
console.log ( i, el.id, this === el) ; // true
} ) ;
See it live: Selectors & collections →
.get()
.get([index]) → element | element[]
Without arguments returns a plain array of all elements; with an index returns that raw element (negative indexes count from the end). Bracket access $(x)[0] also works.
JavaScript Copy $ ( '.item' ) .get ( ) ; // [el, el, el]
$ ( '.item' ) .get ( -1 ) ; // last raw element
See it live: Selectors & collections →
.eq()
.eq(index) → KJ
Reduce the set to the element at the given index, returned as a new chainable set. Negative indexes count from the end.
JavaScript Copy $ ( '.item' ) .eq ( 1 ) .addClass ( 'second' ) ;
$ ( '.item' ) .eq ( -1 ) .text ( 'last' ) ;
See it live: Selectors & collections →
.first() / .last()
.first() → KJ · .last() → KJ
Shortcuts for .eq(0) and .eq(-1).
JavaScript Copy $ ( 'li' ) .first ( ) .addClass ( 'head' ) ;
$ ( 'li' ) .last ( ) .addClass ( 'tail' ) ;
See it live: Selectors & collections →
.index()
.index([element]) → number
Without arguments, the position of the first element among its siblings. With an element, its position within this set.
JavaScript Copy $ ( '.active' ) .index ( ) ; // e.g. 2
See it live: Selectors & collections →
.add()
.add(selector | elements) → KJ
Merge more elements into the set (deduplicated).
JavaScript Copy $ ( '.card' ) .add ( '.banner' ) .addClass ( 'highlight' ) ;
See it live: Selectors & collections →
Content
Content Read and write element content and form values.
.html()
.html([value]) → string | self
Get the first element’s innerHTML, or set it on every element in the set.
JavaScript Copy $ ( '#box' ) .html ( ) ; // read
$ ( '#box' ) .html ( '<b>New</b>' ) ; // write
See it live: DOM manipulation →
.text()
.text([value]) → string | self
Get or set textContent. Setting always escapes — it can never inject HTML.
JavaScript Copy $ ( '#title' ) .text ( 'Safe & sound' ) ;
See it live: DOM manipulation →
.val()
.val([value]) → any | self
Get or set form values. Checkboxes read/write booleans; multi-selects read as arrays.
JavaScript Copy $ ( '#email' ) .val ( ) ; // 'a@b.c'
$ ( '#agree' ) .val ( true ) ; // checks the box
$ ( '#tags' ) .val ( ) ; // ['js', 'css'] for multi-select
See it live: Attributes, properties & data →
Attributes & Data
Attributes & Data HTML attributes, DOM properties, and per-element data storage (backed by a WeakMap, so removed elements are garbage-collected automatically).
.attr()
.attr(name [, value]) · .attr(object) → string | self
Get an attribute from the first element, or set one or many on all elements.
JavaScript Copy $ ( 'img' ) .attr ( 'src' ) ;
$ ( 'img' ) .attr ( 'alt' , 'Logo' ) ;
$ ( 'a' ) .attr ( { href: '/' , title: 'Home' } ) ;
See it live: Attributes, properties & data →
.removeAttr()
.removeAttr(name) → self
Remove an attribute from every element in the set.
JavaScript Copy $ ( 'input' ) .removeAttr ( 'disabled' ) ;
See it live: Attributes, properties & data →
.prop()
.prop(name [, value]) → any | self
Get or set a DOM property (as opposed to an HTML attribute) — checked, disabled, selectedIndex, etc.
JavaScript Copy $ ( '#opt-in' ) .prop ( 'checked' ) ; // true/false
$ ( 'button' ) .prop ( 'disabled' , true ) ;
See it live: Attributes, properties & data →
.data()
.data([key [, value]]) · .data(object) → any | self
Read data-* attributes (JSON auto-parsed) or store arbitrary values against elements. Stored values live in a WeakMap — no memory leaks, no cleanup.
HTML Copy <div id = "u" data-config = '{"admin":true}' > </div >
$('#u').data('config').admin; // true (parsed)
$('#u').data('profile', { id: 7 }); // store anything
$('#u').data(); // all data merged
See it live: Attributes, properties & data →
.removeData()
.removeData(key) → self
Delete a stored data value.
JavaScript Copy $ ( '#u' ) .removeData ( 'profile' ) ;
See it live: Attributes, properties & data →
Classes
Classes Space-separated multi-class strings are supported everywhere.
.addClass()
.addClass(names) → self
Add one or more classes.
JavaScript Copy $ ( '.card' ) .addClass ( 'active highlight' ) ;
See it live: Classes & CSS →
.removeClass()
.removeClass([names]) → self
Remove classes; with no argument, removes all classes.
JavaScript Copy $ ( '.card' ) .removeClass ( 'active' ) ;
$ ( '.card' ) .removeClass ( ) ; // wipe class attribute
See it live: Classes & CSS →
.toggleClass()
.toggleClass(names [, force]) → self
Toggle classes, optionally forcing on/off with a boolean.
JavaScript Copy $ ( '.menu' ) .toggleClass ( 'open' ) ;
$ ( '.menu' ) .toggleClass ( 'open' , isOpen) ;
See it live: Classes & CSS →
.hasClass()
.hasClass(name) → boolean
True if any element in the set has the class.
JavaScript Copy if ( $ ( '#panel' ) .hasClass ( 'open' ) ) close( ) ;
See it live: Classes & CSS →
CSS & Geometry
CSS & Geometry Styles, sizes, positions, scrolling, visibility. Numbers get px automatically (except unitless properties like opacity); CSS custom properties (--vars) are supported.
.css()
.css(name [, value]) · .css(object) → string | self
Get a computed style from the first element, or set styles on all. Numbers become px except for unitless properties. Custom properties (--name) are read with getPropertyValue and written without px.
JavaScript Copy $ ( '.card' ) .css ( 'color' ) ;
$ ( '.card' ) .css ( 'margin-top' , 20 ) ; // → 20px
$ ( '.card' ) .css ( { opacity: .5 , '--accent' : 'tomato' } ) ;
$ ( ':root' ) .css ( '--hue' , 200 ) ; // no px for custom properties
See it live: Classes & CSS →
.width() / .height()
.width([value]) · .height([value]) → number | self
Measured size (from getBoundingClientRect) or set the CSS size. On $(window), returns the viewport size.
JavaScript Copy $ ( '.card' ) .width ( ) ; // 320
$ ( '.card' ) .height ( 200 ) ; // set
$ ( window) .width ( ) ; // viewport
See it live: Geometry, scroll & visibility →
.offset()
.offset() → { top, left }
Position relative to the document, including scroll.
JavaScript Copy const { top } = $ ( '#hero' ) .offset ( ) ;
See it live: Geometry, scroll & visibility →
.position()
.position() → { top, left }
Position relative to the offset parent.
JavaScript Copy const p = $ ( '.tooltip' ) .position ( ) ;
See it live: Geometry, scroll & visibility →
.scrollTop() / .scrollLeft()
.scrollTop([value]) · .scrollLeft([value]) → number | self
Get or set scroll position. Works on elements and on $(window).
JavaScript Copy $ ( window) .scrollTop ( ) ; // read page scroll
$ ( '#panel' ) .scrollTop ( 0 ) ; // scroll to top
See it live: Geometry, scroll & visibility →
.show() / .hide() / .toggle()
.show() · .hide() · .toggle([state]) → self
Instant visibility via display. .hide() remembers the previous display value so .show() restores it correctly.
JavaScript Copy $ ( '.modal' ) .show ( ) ;
$ ( '.hint' ) .toggle ( ) ; // flip
$ ( '.hint' ) .toggle ( isAdmin) ; // force
See it live: Geometry, scroll & visibility →
Insertion & Removal
Insertion & Removal All insertion methods accept HTML strings, elements, jsKjs sets, or plain text — and multiple arguments at once.
.append() / .prepend()
.append(...content) · .prepend(...content) → self
Insert content inside each element, at the end or the start.
JavaScript Copy $ ( '#list' ) .append ( '<li>End</li>' ) ;
$ ( '#list' ) .prepend ( $ ( '<li>Start</li>' ) ) ;
See it live: DOM manipulation →
.before() / .after()
.before(...content) · .after(...content) → self
Insert content outside each element, as a previous or next sibling.
JavaScript Copy $ ( '.section' ) .before ( '<hr>' ) ;
See it live: DOM manipulation →
.appendTo() / .prependTo()
.appendTo(target) · .prependTo(target) → self
Reversed form: insert this set into the target.
JavaScript Copy $ ( '<li>New</li>' ) .appendTo ( '#list' ) ;
See it live: DOM manipulation →
.wrap()
.wrap(html) → self
Wrap each element in the given structure.
JavaScript Copy $ ( 'img' ) .wrap ( '<figure class="frame">' ) ;
See it live: DOM manipulation →
.remove()
.remove() → self
Remove elements from the DOM. Data cleanup is automatic (WeakMap).
JavaScript Copy $ ( '.toast' ) .remove ( ) ;
See it live: DOM manipulation →
.empty()
.empty() → self
Remove all children of each element.
JavaScript Copy $ ( '#results' ) .empty ( ) ;
See it live: DOM manipulation →
.clone()
.clone([deep = true]) → KJ
Deep-copy the elements.
JavaScript Copy $ ( '#template-row' ) .clone ( ) .appendTo ( '#table' ) ;
See it live: DOM manipulation →
.replaceWith()
.replaceWith(content) → self
Replace each element with new content.
JavaScript Copy $ ( '.old-banner' ) .replaceWith ( '<div class="new">Hi</div>' ) ;
See it live: DOM manipulation →
Traversal
Traversal Walk the tree. Every method returns a new chainable set; results are deduplicated.
.find()
.find(selector) → KJ
All descendants matching a selector.
JavaScript Copy $ ( '#app' ) .find ( '.btn' ) .addClass ( 'ready' ) ;
See it live: DOM traversal →
.filter()
.filter(selector | fn) → KJ
Keep only matching elements. Accepts a selector or a predicate (i, el) => boolean.
JavaScript Copy $ ( '.item' ) .filter ( '.active' ) ;
$ ( '.item' ) .filter ( ( i, el) => el.dataset.price > 100 ) ;
See it live: DOM traversal →
.not()
.not(selector | fn(i, el) | element | collection) → KJ
Drop matching elements. Accepts a selector, an element or collection, or a predicate function.
JavaScript Copy $ ( '.item' ) .not ( '.sold-out' ) .show ( ) ;
$ ( '.item' ) .not ( ( i, el) => el.dataset.price > 100 ) ;
See it live: DOM traversal →
.is()
.is(selector | fn(i, el) | element) → boolean
Test whether any element in the set matches a selector, element, collection or predicate.
JavaScript Copy if ( $ ( e.target) .is ( 'button' ) ) { … }
See it live: DOM traversal →
.closest()
.closest(selector) → KJ
Nearest matching ancestor (including the element itself). The backbone of event delegation.
JavaScript Copy $ ( e.target) .closest ( '.card' ) .addClass ( 'selected' ) ;
See it live: DOM traversal →
.parent() / .parents()
.parent() · .parents([selector]) → KJ
Direct parent, or all ancestors (optionally filtered).
JavaScript Copy $ ( '.btn' ) .parent ( ) ;
$ ( '.btn' ) .parents ( '.section' ) ;
See it live: DOM traversal →
.children()
.children([selector]) → KJ
Direct children, optionally filtered.
JavaScript Copy $ ( '#list' ) .children ( 'li.active' ) ;
See it live: DOM traversal →
.siblings()
.siblings([selector]) → KJ
All siblings, optionally filtered.
JavaScript Copy $ ( '.tab.active' ) .siblings ( ) .removeClass ( 'active' ) ;
See it live: DOM traversal →
.next() / .prev()
.next([selector]) · .prev([selector]) → KJ
Adjacent siblings, optionally required to match a selector.
JavaScript Copy $ ( '.step.current' ) .next ( ) .addClass ( 'upcoming' ) ;
See it live: DOM traversal →
Events
Events Modern event handling with delegation, namespaces, once-only handlers, and custom events with payloads.
.on()
.on(types [, delegateSelector], handler) → self
Attach handlers. Multiple space-separated events and .namespace suffixes are supported. With a delegate selector, the handler fires for matching descendants — including ones added later — and this is the matched element.
JavaScript Copy $ ( '.btn' ) .on ( 'click' , e => save( ) ) ;
$ ( '.btn' ) .on ( 'click.menu keydown.menu' , handler) ;
// Delegation — survives DOM swaps
$ ( '#list' ) .on ( 'click' , '.item' , function ( e) {
$ ( this ) .toggleClass ( 'selected' ) ;
} ) ;
See it live: Events →
.one()
.one(types [, delegateSelector], handler) → self
Like .on() but the handler runs at most once.
JavaScript Copy $ ( '#intro' ) .one ( 'click' , dismiss) ;
See it live: Events →
.off()
.off([types] [, handler]) → self
Remove handlers — all of them, by event type, by namespace, or by specific handler reference.
JavaScript Copy $ ( '.btn' ) .off ( 'click' ) ;
$ ( '.btn' ) .off ( '.menu' ) ; // whole namespace
$ ( '.btn' ) .off ( ) ; // everything
See it live: Events →
.trigger()
.trigger(type [, detail]) → self
Dispatch an event (bubbling, cancelable). The optional payload arrives as the handler’s second argument.
JavaScript Copy $ ( '#app' ) .on ( 'cart:add' , ( e, item) => render( item) ) ;
$ ( '#app' ) .trigger ( 'cart:add' , { sku: 'A-1' } ) ;
See it live: Events →
.hover()
.hover(enterFn [, leaveFn]) → self
Shorthand for mouseenter/mouseleave.
JavaScript Copy $ ( '.card' ) .hover (
function ( ) { $ ( this ) .addClass ( 'lift' ) ; } ,
function ( ) { $ ( this ) .removeClass ( 'lift' ) ; } ) ;
See it live: Events →
Shortcuts
.click([fn]) .change([fn]) .submit([fn]) … → self
With a handler: binds it. Without: triggers the event. Available for click, dblclick, change, input, submit, keydown, keyup, keypress, mousedown, mouseup, mousemove, mouseenter, mouseleave, scroll, resize, touchstart, touchend, contextmenu.
JavaScript Copy $ ( '#save' ) .click ( ( ) => submit( ) ) ;
$ ( '#save' ) .click ( ) ; // programmatic click
See it live: Events →
.focus() / .blur()
.focus([fn]) · .blur([fn]) → self
Bind a handler, or move focus when called without one.
JavaScript Copy $ ( '#search' ) .focus ( ) ; // focus the field
$ ( '#search' ) .focus ( onFocus) ; // bind
See it live: Events →
AJAX
AJAX Powered by fetch. Every call returns a native Promise (so await just works) with jQuery-style .done/.fail/.always shims attached.
$.ajax()
$.ajax(url | options [, options]) → Promise
Full-control requests. Options: url, method (or jQuery’s type), data (object → urlencoded or querystring; FormData; string), json: true (send JSON body), dataType (’json’ | ’auto’), headers, timeout (ms, auto-aborts), credentials, and callbacks success(data, status, res), error(err), complete(). The promise also has .abort().
JavaScript Copy const p = $ .ajax ( {
url: '/api/items' , method: 'POST' ,
data: { title: 'Hello' } , json: true ,
headers: { 'X-Token' : 'abc' } , timeout: 5000 ,
} ) ;
p.done ( d => render( d) ) .fail ( err => alert( err.status) ) ;
// or simply: const d = await p;
See it live: AJAX with $.ajax →
$.get()
$.get(url [, data] [, success]) → Promise
GET shorthand; data becomes the query string.
JavaScript Copy const html = await $ .get ( '/partials/nav.html' ) ;
$ .get ( '/api/search' , { q: 'cats' } , render) ;
See it live: $.get, $.post & $.getJSON →
$.post()
$.post(url [, data] [, success]) → Promise
POST shorthand (urlencoded body by default).
JavaScript Copy await $ .post ( '/api/save' , { name: 'Ada' } ) ;
See it live: $.get, $.post & $.getJSON →
$.getJSON()
$.getJSON(url [, data] [, success]) → Promise
GET with forced JSON parsing.
JavaScript Copy const users = await $ .getJSON ( '/api/users' ) ;
See it live: $.get, $.post & $.getJSON →
.load()
.load(url [ + ’ selector’] [, done]) → self
Fetch HTML into the element. Add a space + selector to insert only a fragment of the response.
JavaScript Copy $ ( '#panel' ) .load ( '/partials/news.html' ) ;
$ ( '#panel' ) .load ( '/page.html #main' ) ;
See it live: Loading HTML fragments →
.serialize()
.serialize() → string
URL-encode a form’s fields.
JavaScript Copy $ ( '#signup' ) .serialize ( ) ; // "name=Ada&plan=pro"
See it live: Forms & serialization →
.serializeObject()
.serializeObject() → object
A form’s fields as a plain object (jsKjs extra).
JavaScript Copy const { email } = $ ( '#signup' ) .serializeObject ( ) ;
See it live: Forms & serialization →
Hyper — Declarative AJAX
Hyper — Declarative AJAX htmx-style: describe requests in HTML with kj-* attributes and never write the handler. A MutationObserver auto-binds content added later, including content swapped in by Hyper itself.
kj-get / kj-post / kj-put / kj-patch / kj-delete
kj-<verb>="/url"
The URL to request with that HTTP verb. Forms send their fields; named inputs, selects and textareas send their own value. Bodies are URL-encoded (multipart when a form contains file inputs). Default triggers: forms → submit, inputs/selects → change, everything else → click.
HTML Copy <button kj-get = "/api/joke" kj-target = "#out" > Joke</button >
<form kj-post = "/api/subscribe" kj-target = "#msg" >
<input name = "email" type = "email" >
<button > Subscribe</button >
</form >
See it live: Declarative requests →
kj-target
kj-target="#selector"
Where the response HTML goes (default: the element itself).
HTML Copy <button kj-get = "/api/stats" kj-target = "#stats" > Refresh</button >
See it live: Declarative requests →
kj-swap
kj-swap="innerHTML | outerHTML | textContent | beforebegin | afterbegin | beforeend | afterend | none"
How the response is inserted into the target. outerHTML replaces the target entirely; the four position values insert adjacent to it; none makes the request without touching the DOM.
HTML Copy <button kj-delete = "/api/items/7" kj-target = "#row-7"
kj-swap = "outerHTML" > Delete</button >
See it live: Targets & swaps →
kj-trigger
kj-trigger="event [delay:Nms] | load | revealed | every Ns"
When to fire: any DOM event (with optional debounce), load (immediately), revealed (when scrolled into view, via IntersectionObserver), or every Ns (polling).
HTML Copy <input name = "q" kj-get = "/api/search"
kj-trigger = "keyup delay:300ms" kj-target = "#results" >
<div kj-get = "/api/comments" kj-trigger = "revealed" > …</div >
<span kj-get = "/api/price" kj-trigger = "every 10s" > </span >
See it live: Triggers & debouncing →
kj-confirm
kj-confirm="message"
Show a native confirm dialog before requesting.
HTML Copy <button kj-delete = "/api/acct" kj-confirm = "Really delete?" > ✕</button >
See it live: Confirmations & loading indicators →
kj-indicator
kj-indicator="#selector"
Element to show while the request is in flight (the trigger also gets aria-busy="true").
HTML Copy <button kj-get = "/slow" kj-indicator = "#spinner" > Go</button >
<span id = "spinner" hidden > Loading…</span >
See it live: Confirmations & loading indicators →
kj-include / kj-vals
kj-include="#form" · kj-vals=’{"k":"v"}’
Send extra data: the fields of another form, and/or literal JSON values.
HTML Copy <button kj-post = "/api/filter" kj-include = "#filters"
kj-vals = '{"page": 2}' kj-target = "#grid" > Next</button >
See it live: Sending extra data →
kj-push-url
kj-push-url="true | /path"
Push the request URL (or a given path) into browser history after a successful swap.
HTML Copy <a kj-get = "/products?page=2" kj-target = "#grid"
kj-push-url = "true" > Page 2</a >
See it live: History & deep links →
Lifecycle events
kj:before · kj:after · kj:error · kj:load
kj:before (before the request), kj:after (response received, before the swap; detail.html) and kj:error (detail.error.status) fire on the requesting element. kj:load fires on the target after the swap — or on its former parent when outerHTML replaced it. All bubble.
JavaScript Copy $ ( '#btn' ) .on ( 'kj:error' , ( e, d) =>
toast( 'Failed: ' + d.error.status) ) ;
$ ( '#grid' ) .on ( 'kj:load' , highlightNew) ;
See it live: Polling →
Pulse — Reactivity
Pulse — Reactivity Alpine-style: declare state on an element with kj-data; bind it with directives. Mutating state re-renders the component. No virtual DOM, no build step. Inside expressions, $el is the element and $event the event.
kj-data
kj-data="{ … }" | kj-data="componentName"
Declares a component and its reactive scope. An init() method, if present, runs on mount. Pass a registered component name to reuse logic.
HTML Copy <div kj-data = "{ count: 0, open: false }" > …</div >
<div kj-data = "dropdown" > …</div > <!-- registered -->
See it live: Reactive state →
kj-text / kj-html
kj-text="expr" · kj-html="expr"
Bind textContent or innerHTML to an expression. Prefer kj-text for anything user-supplied.
HTML Copy <span kj-text = "count" > </span >
<p kj-text = "name ? 'Hi ' + name : 'Who?'" > </p >
See it live: Text & HTML binding →
kj-show
kj-show="expr"
Show/hide via display based on a truthy expression.
HTML Copy <ul kj-show = "open" > …</ul >
See it live: Conditional display →
kj-model
kj-model="property"
Two-way binding for text, number and range inputs, textareas, selects, checkboxes (booleans) and radio buttons (the checked radio’s value). The field being typed in is never rewritten mid-typing; programmatic changes update it immediately.
HTML Copy <input kj-model = "email" >
<input type = "checkbox" kj-model = "agreed" >
See it live: Two-way binding →
@event / kj-on:event
@click="expr" · kj-on:input="expr" · modifiers: .prevent .stop .enter .escape
Run an expression on an event. Modifiers call preventDefault/stopPropagation or filter keys.
HTML Copy <button @click = "count++" > +1</button >
<form @submit.prevent = "save()" > …</form >
<input @keyup.enter = "search($el.value)" >
See it live: Event directives →
:attr / kj-bind:attr
:src="expr" · kj-bind:class="expr"
Bind any attribute to an expression. :class merges with the element’s static classes; false/null removes the attribute.
HTML Copy <img :src = "user.avatar" :alt = "user.name" >
<button :disabled = "saving" > Save</button >
<div :class = "open ? 'expanded' : ''" > …</div >
See it live: Attribute binding →
$.component()
$.component(name, (...args) => state)
Register a reusable component factory, then use it with kj-data="name" or with arguments: kj-data="name(4, 'Docs')". An init(el) method receives the root element.
JavaScript Copy $ .component ( 'rating' , ( initial = 0 ) => ( {
value: initial,
rate( n) { this .value = n; } ,
} ) ) ;
// <div kj-data="rating(4)">…</div>
See it live: Reusable components →
$.store()
$.store(name [, initial]) → reactive object
Create or retrieve a global reactive store. Any component reading it re-renders when it changes. Getters work as computed values.
JavaScript Copy const cart = $ .store ( 'cart' , {
items: [ ] ,
get total( ) { return this .items.length; } ,
} ) ;
cart.items.push ( { sku: 'A-1' } ) ; // UI updates
See it live: Global stores →
$.reactive()
$.reactive(object) → proxy
A standalone reactive proxy without auto-rendering — for your own change-tracking logic.
JavaScript Copy const state = $ .reactive ( { x: 1 } ) ;
See it live: Reactive state →
Motion — Animation
Motion — Animation GSAP-style tweening on requestAnimationFrame. Transform shorthands (x, y, rotate, scale…) plus any numeric CSS property. Durations in seconds. All tweens return Promises.
$.to()
$.to(target, { …props, duration, delay, ease, stagger, onComplete }) → Promise
Tween to a state. stagger offsets each element’s start; onComplete fires after the last finishes. Also chainable on sets: $(sel).to(props).
JavaScript Copy $ .to ( '.card' , { x: 200 , rotate: 10 , opacity: .8 ,
duration: .6 , ease: 'back.out' } ) ;
await $ .to ( '#modal' , { opacity: 0 , duration: .3 } ) ;
$ ( '#modal' ) .hide ( ) ;
See it live: Tweens →
$.from()
$.from(target, props) → Promise
Jump to the given state, then tween back to the original — the classic entrance pattern.
JavaScript Copy $ .from ( '.hero h1' , { y: 40 , opacity: 0 ,
duration: .8 , ease: 'power2.out' } ) ;
See it live: From & fromTo →
$.fromTo()
$.fromTo(target, fromProps, toProps) → Promise
Explicit start and end states.
JavaScript Copy $ .fromTo ( '.badge' , { scale: 0 } ,
{ scale: 1 , duration: .5 , ease: 'elastic.out' } ) ;
See it live: From & fromTo →
$.timeline()
$.timeline({ paused?, onComplete?, ...defaults }) → timeline
Sequence tweens. Steps run in order; position '<' starts a step with the previous one; '+=0.3' waits 0.3 s first. Methods: .to(), .from(), .fromTo(), .add(fn) (waits if fn returns a Promise), .play() → Promise. Auto-plays unless paused: true.
JavaScript Copy const tl = $ .timeline ( { paused: true , duration: .5 , ease: 'power2.out' } )
.from ( '.hero' , { opacity: 0 } )
.from ( '.hero h1' , { y: 30 } )
.from ( '.hero p' , { y: 30 } , '<' ) // together with the h1
.from ( '.cta' , { scale: .8 } , '+=0.2' ) ;
await tl.play ( ) ;
See it live: Timelines →
stagger
stagger: seconds
Offset each element in a multi-element tween — the signature "cascade" effect.
JavaScript Copy $ .to ( '.item' , { y: 0 , opacity: 1 ,
duration: .4 , stagger: .08 } ) ;
See it live: Stagger →
Easings
ease: name | (t) => number
Built in: linear, ease-in, ease-out, ease-in-out, power2.in, power2.out, power2.inOut, back.out, elastic.out, bounce.out — exposed as $.easings — or pass any function mapping 0→1 progress.
JavaScript Copy $ .to ( '.ball' , { y: 200 , ease: 'bounce.out' , duration: 1 } ) ;
$ .to ( '.dot' , { x: 100 , ease: t => t * t } ) ;
See it live: Tweens →
jQuery Effect Shims
jQuery Effect Shims The classics, rebuilt on the Motion engine. Durations in milliseconds , exactly as jQuery developers expect.
.fadeIn() / .fadeOut() / .fadeToggle()
.fadeIn([ms = 400] [, complete]) → self
Fade elements in (from hidden) or out (hiding when done).
JavaScript Copy $ ( '.toast' ) .fadeIn ( 300 ) ;
$ ( '.toast' ) .fadeOut ( 300 , function ( ) { $ ( this ) .remove ( ) ; } ) ;
See it live: Classic effects →
.slideDown() / .slideUp() / .slideToggle()
.slideDown([ms = 400] [, complete]) → self
Animate height to reveal or collapse.
JavaScript Copy $ ( '#faq-answer' ) .slideToggle ( 250 ) ;
See it live: Classic effects →
.animate()
.animate(props [, ms = 400] [, ease] [, complete]) → self
jQuery-signature tween of numeric CSS properties.
JavaScript Copy $ ( '.box' ) .animate ( { marginLeft: 100 , opacity: .5 } , 600 ) ;
See it live: Classic effects →
Utilities
Utilities Small helpers on the $ namespace.
$.each()
$.each(arrayOrObject, (keyOrIndex, value) => {})
Iterate arrays, array-likes, or plain objects.
JavaScript Copy $ .each ( { a: 1 , b: 2 } , ( k, v) => console.log ( k, v) ) ;
See it live: Utilities →
$.map()
$.map(collection, fn) → array
Map + flatten one level.
JavaScript Copy $ .map ( [ 1 , 2 ] , n => [ n, n * 10 ] ) ; // [1,10,2,20]
See it live: Utilities →
$.extend()
$.extend([deep], target, …sources) → target
Merge objects; pass true first for deep merge.
JavaScript Copy $ .extend ( defaults, options) ;
$ .extend ( true , config, { api: { retries: 3 } } ) ;
See it live: Utilities →
$.debounce()
$.debounce(fn [, wait = 300]) → fn
Returns a function that fires only after calls stop for wait ms.
JavaScript Copy $ ( '#q' ) .on ( 'input' , $ .debounce ( search, 300 ) ) ;
See it live: Debounce & throttle →
$.throttle()
$.throttle(fn [, wait = 300]) → fn
Returns a function that fires at most once per wait ms.
JavaScript Copy $ ( window) .on ( 'scroll' , $ .throttle ( onScroll, 100 ) ) ;
See it live: Debounce & throttle →
$.param()
$.param(object) → string
Serialize an object to a query string.
JavaScript Copy $ .param ( { a: 1 , b: 'x y' } ) ; // "a=1&b=x+y"
See it live: Utilities →
$.parseHTML()
$.parseHTML(html) → element[]
Parse an HTML string into an array of nodes.
JavaScript Copy const [ li] = $ .parseHTML ( '<li>Hi</li>' ) ;
See it live: Utilities →
$.escape()
$.escape(string) → string
HTML-escape text — use it whenever you string-build HTML from user data.
JavaScript Copy $ ( '#out' ) .html ( '<b>' + $ .escape ( userInput) + '</b>' ) ;
See it live: Utilities →
$.uuid()
$.uuid() → string
A cryptographically strong UUID (v4).
JavaScript Copy const id = $ .uuid ( ) ;
See it live: Utilities →
Type checks
$.isArray(x) · $.isFunction(x) · $.isPlainObject(x) · $.trim(s)
Small predicates and string trim, kept for jQuery compatibility.
JavaScript Copy $ .isPlainObject ( { } ) ; // true
$ .isArray ( 'nope' ) ; // false
See it live: Utilities →
$.noConflict()
$.noConflict() → $
Restore the previous window.$ and return jsKjs (also always available as kj and jsKjs).
JavaScript Copy const j = $ .noConflict ( ) ;
j( '#app' ) .addClass ( 'ready' ) ;
See it live: Utilities →
$.version
$.version → string
The library version.
JavaScript Copy console.log ( $ .version) ; // "1.0.0"
See it live: Utilities →
Browser support Evergreen browsers: Chrome and Edge 90+, Firefox 90+, Safari 15+. Internet Explorer and pre-2021 browsers are unsupported by design — that is where the small size comes from.