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