I can get all <mark>
elements and set them background like:
element.find('mark').css( "background-color", "red");
But how can I set background just for second or third argument (third mark), i tried something like this:
element.find('mark')[3].css( "background-color", "red");
(element.find('mark')[3]).css( "background-color", "red");
Above example doesn't work, please help me
Greetings rizon
When you access a jQuery object by index it returns the underlying DOMElement at that index. The issue you have there is that DOMElements do not have a css()
method. Instead you should use eq()
to get the element at the required index wrapped in a jQuery object. Try this:
element.find('mark').eq(3).css('background-color', 'red');