JSFiddle - React, Tailwind, and code Playground
by nate
JavaScript
for (var i = 1; i <= 10; i += 1) {
$('<div>', { text: i }).appendTo('body');
}
// Grab the fourth div
$('div:nth-child(4)').css('color', 'red');
// Grab the eighth div (zero-indexed)
$('div').eq(7).css('color', 'green');
// Grab the fifth div (zero-indexed)
$('div').each(function (i, item) {
if (i === 4) {
$(item).css('color', 'orange');
}
});