There are several ways to do this with jQuery.
To select both of the example spans:
Using the pseudoclasse :first-child
in the selector:
var primeiros = $(".container .iconset:first-child");
Using pseudoclasse :nth-child
in the selector:
var primeiros = $(".container .iconset:nth-child(1)");
Using pseudoclasse :first-of-type
(which selects the first element of a certain type, in this case , spans):
var primeiros = $(".container .iconset:first-of-type");
To select only the first span of the first container:
With the first
method:
var primeiro = $(".container .iconset").first();
Using pseudoclasse :first
(jQuery extension, not part of CSS):
var primeiro = $(".container .iconset:first");
With the eq
method:
var primeiro = $(".container .iconset").eq(0);
With pseudoclasse :eq
(jQuery extension, not part of CSS):
var primeiro = $(".container .iconset:eq(0)");
The difference is that all the methods in this second group first select all the elements that meet the selector, and only then takes the first element between them.