AnonyMouse
AnonyMouse

Reputation: 18630

jQuery get by class and attribute

Hi I have a select like:

<select id="item_OfficeUserId" class="dropdownauditor" name="item.OfficeUserId" invoicelineid="33">

In jQuery I can get it by its class:

$(".dropdownauditor")

Is there a way to get it based on its class and it attribute invoicelineid="33" as well?

There will be more than one with class="dropdownauditor". I want to get the selected item of the particular select. I was using:

$(".dropdownauditor").change(function () {
    $(".dropdownauditor option:selected").each(function () {
    ...
    }
}

But this is running through the second part twice. ie. It tis then finding the selected for every select with class="dropdownauditor" Is is possible to only find only one with invoicelineid="33"?

Upvotes: 25

Views: 36950

Answers (1)

Andrew Whitaker
Andrew Whitaker

Reputation: 126042

$(".dropdownauditor[invoicelineid='33']")

Using the attribute equals selector.

Upvotes: 67

Related Questions