문제

I need to find the tab index and id of a tab that has two particular attributes. Here's an example tab:

<div id="tabs-2" aria-labelledby="ui-id-2" class="ui-tabs-panel ui-widget-content ui-corner-bottom" role="tabpanel" aria-expanded="true" aria-hidden="false" style="display: block;" tabcounter="2" symbol="GOOG" exchange="NASDAQ">

In this case, I want it to spit out the index as well as "tabs-2" when it identifies that the symbol is "GOOG" and the exchange is "NASDAQ".

Thanks.

도움이 되었습니까?

해결책

$('div[symbol=GOOG][exchange[NASDAQ]').attr('tabindex')

it should do the trick

다른 팁

To select an element based on attributes, use the "attributes selector"

var elem = $('[symbol="GOOG"][exchange="NASDAQ"]')

then to get the ID and index

var id    = elem.prop('id');
var index = elem.index();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top