Element Selection & DOM Manipulation
DOM Queries
Select elements to see them highlighted
Test Element 1
Test Element 2
Test Element 3 (special)
DOM Manipulation
Original content
CSS & Classes
CSS Target Element
Selection API
Core Selectors
$(selector) → NodeList
$('.class') → NodeList
$('#id') → NodeList
$('tag') → NodeList
DOM Manipulation
html(content?) → NodeList|string
text(content?) → NodeList|string
append(content) → NodeList
prepend(content) → NodeList
remove() → NodeList
CSS & Classes
css(styles) → NodeList
addClass(className) → NodeList
removeClass(className) → NodeList
toggleClass(className) → NodeList
Examples
// Element selection const elements = $('.my-class'); const byId = $('#my-id'); $('.target').html('<b>New content</b>'); $('.target').text('Plain text'); $('.container').append('<p>Added</p>'); $('.element').css({ 'color': 'red', 'background': 'blue' }); $('.element').addClass('active');