jQuery-compatible API with 90+ chainable methods for traversal, manipulation, events, and more.
$('selector') or Domma('selector')
Select elements using CSS selectors, DOM elements, or HTML strings.
// CSS selector
$('.class')
$('#id')
$('div.container > p')
// DOM element
$(document.body)
$(element)
// HTML string
$('Content')
// Collection from NodeList
$(document.querySelectorAll('p'))
Limit your search to a specific element for better performance and clarity.
// Search within specific container
const container = document.getElementById('container');
$('li', container).addClass('highlight');
// Equivalent to chaining
$('#container').find('li').addClass('highlight');
// Performance benefit: searches smaller subset
$('.item', containerEl).css('color', 'blue');
Navigate the DOM tree with chainable methods.
find()
children()
parent()
parents()
closest()
siblings()
next()
prev()
nextAll()
prevAll()
first()
last()
eq()
filter()
not()
has()
is()
add()
contents()
offsetParent()
// Find descendants
$('#container').find('.item')
// Navigate up
$('.item').parent()
$('.item').closest('.container')
$('.item').parents('div')
// Siblings
$('.active').siblings()
$('.item').next()
$('.item').prev()
// Filtering
$('.items').filter('.active')
$('.items').not('.disabled')
$('.items').eq(2) // Third element
$('.items').first()
$('.items').last()
Get and set element content, attributes, and values.
html()
text()
val()
attr()
removeAttr()
prop()
removeProp()
data()
removeData()
// Get/set HTML content
$('#box').html() // Get
$('#box').html('New') // Set
// Get/set text content
$('#box').text()
$('#box').text('Plain text')
// Get/set form values
$('input').val()
$('input').val('New value')
// Attributes
$('img').attr('src')
$('img').attr('src', 'new.jpg')
$('img').attr({ src: 'img.jpg', alt: 'Image' })
// Data attributes
$('#el').data('id') // data-id
$('#el').data('id', '123')
Manipulate styles and CSS classes.
css()
addClass()
removeClass()
toggleClass()
hasClass()
show()
hide()
toggle()
// Get/set CSS
$('#box').css('color')
$('#box').css('color', 'red')
$('#box').css({ color: 'red', fontSize: '16px' })
// Classes
$('#box').addClass('active')
$('#box').removeClass('active')
$('#box').toggleClass('active')
$('#box').hasClass('active') // Returns boolean
// Visibility
$('#box').show()
$('#box').hide()
$('#box').toggle()
Insert, replace, and remove elements.
append()
prepend()
after()
before()
appendTo()
prependTo()
insertAfter()
insertBefore()
wrap()
wrapAll()
wrapInner()
unwrap()
clone()
remove()
detach()
empty()
replaceWith()
replaceAll()
// Inserting content
$('#list').append('Attach, trigger, and manage events.
on()
off()
one()
trigger()
click()
dblclick()
mouseenter()
mouseleave()
mouseover()
mouseout()
mousemove()
mousedown()
mouseup()
hover()
focus()
blur()
change()
submit()
keydown()
keyup()
keypress()
scroll()
resize()
load()
// Basic event binding
$('#btn').on('click', function(e) {
console.log('Clicked!', this);
});
// Event delegation
$('#list').on('click', '.item', handler);
// One-time event
$('#btn').one('click', handler);
// Remove events
$('#btn').off('click');
$('#btn').off('click', specificHandler);
// Trigger events
$('#btn').trigger('click');
// Shorthand methods
$('#btn').click(handler);
$('#input').focus(handler);
$('#form').submit(handler);
// Hover (mouseenter + mouseleave)
$('#box').hover(enterFn, leaveFn);
Animate elements with built-in effects.
fadeIn()
fadeOut()
fadeToggle()
fadeTo()
slideDown()
slideUp()
slideToggle()
animate()
stop()
delay()
// Fade effects
$('#box').fadeIn(400)
$('#box').fadeOut(400)
$('#box').fadeToggle()
$('#box').fadeTo(400, 0.5) // Fade to 50% opacity
// Slide effects
$('#box').slideDown(400)
$('#box').slideUp(400)
$('#box').slideToggle()
// Custom animation
$('#box').animate({
opacity: 0.5,
marginLeft: '100px'
}, 500)
// Chained animations with delay
$('#box')
.fadeOut(200)
.delay(500)
.fadeIn(200)
Get and set element dimensions and position.
width()
height()
innerWidth()
innerHeight()
outerWidth()
outerHeight()
offset()
position()
scrollTop()
scrollLeft()
// Dimensions
$('#box').width() // Content width
$('#box').width(200) // Set width
$('#box').height()
$('#box').innerWidth() // Including padding
$('#box').outerWidth() // Including padding + border
$('#box').outerWidth(true) // Including margin
// Position
$('#box').offset() // { top, left } relative to document
$('#box').position() // { top, left } relative to offset parent
// Scroll
$(window).scrollTop()
$(window).scrollTop(0) // Scroll to top
$('#box').scrollLeft()
Iterate and work with element collections.
each()
map()
get()
index()
toArray()
slice()
length
// Iterate
$('.items').each(function(index, element) {
console.log(index, $(this).text());
});
// Map to values
const texts = $('.items').map(function() {
return $(this).text();
}).toArray();
// Get raw elements
$('.items').get() // All elements as array
$('.items').get(0) // First element
$('.items')[0] // Same as get(0)
// Index
$('.items').index($('.active')) // Position of element
// Length
$('.items').length // Number of elements
All 90+ methods available in the DOM namespace.
Navigate the DOM tree to find related elements (20 methods).
Get and set element content and attributes (9 methods).
Manipulate styles and CSS classes (8 methods).
Insert, move, copy and remove DOM elements (14 methods).
Attach, remove and trigger event handlers (24 methods).
Animate elements with fades, slides and custom animations (10 methods).
Get and set element dimensions and positions (10 methods).