Aztaroth
Aztaroth

Reputation: 21

Selector for finding the first select list with a specific value

I have several selects on a page with the same class VirtueClass. Now I want to change the selected item on the first select on the page where the value equals 0, e.g. the first "free" select on the page.

How can I write such a selector?

Upvotes: 2

Views: 85

Answers (1)

Naftali
Naftali

Reputation: 146310

$('.VirtueClass').filter(function(){
    return this.value == 0;
 }).eq(0);

This will select the first item that is set to zero

Upvotes: 1

Related Questions