benhowdle89
benhowdle89

Reputation: 37464

jQuery second of matched class selector

Using jQuery how can I tell if the second "here" div has been clicked?

http://jsfiddle.net/qBZLM/

<div class="image"></div>
<div class="image"></div>
<div class="image here"></div>
<div class="image here"></div>
<div class="image here"></div>

Upvotes: 0

Views: 105

Answers (3)

Jay Blanchard
Jay Blanchard

Reputation: 34416

$('.here').eq(1).click() should work.

Upvotes: 1

eos87
eos87

Reputation: 9353

$(".here:eq(1)").click(function(){
    do_something();
});

Upvotes: 5

Amin Eshaq
Amin Eshaq

Reputation: 4024

This is an option. Here is a fiddle

$('.image.here:eq(1)').click(function(){

    alert('here')
        });​

Upvotes: 5

Related Questions