What is the jQuery equivalent of querySelector? The only way I've found so far is to select all then pick the first selection:
$(selectorString)[0]
With the above expression, is jQuery smart enough to stop after finding the first match?
Update: @Mutnowski suggested using eq() and first, but after reading the jQuery documentation those two methods seem to have the same drawback: jQuery will first get all matches, then only filter out the first element.
You want .eq(index) to get an index
$("td").eq(2)
$("td:eq(2)")
http://api.jquery.com/eq/
If you want just the first use .first()
$("tr").first()
$("tr:first")
http://api.jquery.com/first/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With