T
T
timtimIT2015-10-22 18:18:24
JavaScript
timtimIT, 2015-10-22 18:18:24

How to find the first element with a given class using jquery?

Hello.

How to find the first element with a given class using jquery?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
A
Alexander Litvinenko, 2015-10-22
@timtimIT

$('.class:first')
or

$('.class').first()
$('.class').eq(1)

but the first option is the most optimal in terms of resources

L
LittleFatNinja, 2015-10-22
@LittleFatNinja

$('.class').eq(1)

S
Stalker_RED, 2015-10-22
@Stalker_RED

$('div.myclass').first()

S
Super User, 2015-10-22
@sergeystepanov1988

$(document.querySelector('.class'))

N
Nikolai Shabalin, 2015-10-23
@nikolayshabalin

document.getElementsByClassName('class-name')[0];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question