I am currently implementing the following code snippet:
$('.js-toprow:nth-child(even)').css("background:", "#ddd");
$('.js-toprow:nth-child(odd)').css("background:", "#ff0000");
Within the function:
function resetSlides() {
container.css({
'top': -1 * item_height
});
// >> Using it here <<
}
In order to alternate between two different colors for an element tree.
The complete code can be viewed here (already resolved): "Working" script returning Uncaught DOMException: Failed to execute 'insertBefore' on 'Node': The new child element contains the parent
In this scenario, the variable that needs to be styled is "slides", so I experimented with using
slides.css({'background': '#000'});
within the function for testing purposes, and it was successful. However, I still require the even and odd styling.
It is essential to achieve this using jQuery alone since applying CSS leads to restyling of the children as new elements are inserted at the beginning of the list.