selectors: how to replace :eq with .eq()
I am trying to switch from `:eq()` to `.eq()`, for two reasons:
1) I find it easier to read, especially in my case where calculations are used to compute the index
2) jQuery docs saying:
-
Because
:eq()
is a jQuery extension and not part of the CSS specification, queries using
:eq()
cannot take advantage of the performance boost provided by the native DOM
querySelectorAll()
method. For better performance in modern browsers, use
$("your-pure-css-selector").eq(index)
instead.
However, I'm not sure how to re-write this selector (the h1 at the end is what gets me confused):
- $(".productsList .product:eq(" + ($i * 4 + $j - 1) + ") h1")
Any ideas?
Thanks