How can you make the first element a common class in many other elements?

There is a list of items which are marked with different classes
the <ul>
<li class="one">1</li>
<li class="one">2</li>
<li class="one">3</li>
<li class="two">4</li>
<li class="two">5</li>
</ul>

Need only the first element with the class one given the style, and the same with the class two. The number of such points is not limited and therefore from the category of pseudo-classes :nth-child is not appropriate here
July 2nd 19 at 13:26
1 answer
July 2nd 19 at 13:28
Solution
.first()
Returns the first element from all the selected. Equivalent .eq(0). The method has one use:
.first():jQueryv:1.4
The method has no parameters.

Examples of usage:
$("div").first() will return the first div element on the page.
$("div.bigBlock").first() will return the first div with the class bigBlock.

goo.gl/YivVZF

Find more questions by tags JavaScriptHTMLCSS