我有三个代表std1,std2等标准的链接(锚标记)。我想获得活跃的类值。
mService.getAPI().getAlbums().flatMap(new Func1<List<PhotoAlbum>, Observable<GetDriversResponse>>() {
@Override
public Observable<GetDriversResponse> call(GetDriversResponse mResponse) {
return mDatabaseHelper.setMyBus(mResponse);
}
}).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<GetDriversResponse>() {
@Override
public void call(List<PhotoAlbum> photoAlbums{view().showSearchResult(photoAlbums); }}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
throwable.printTrack
}
}));
的jQuery
<li data-interest="1" class="check <? if($std_id == 1){?> class="active"<?}?>" >
<a href="#1" onclick="changeDiv('1','S1')" data-toggle="tab" title="S1">
<span class="round-tabs green">
<span class="grade_catgory">S1</span>
</span>
</a></li>
<li data-interest="2" class="check <? if($std_id == 2){?> class="active"<?}?>" >
<a onclick="changeDiv('2','S2')" data-toggle="tab" title="S2">
<span class="round-tabs yellow">
<span class="grade_catgory">S2</span>
</span>
</a>
</li>
我想要像1,2,等等的值。我可以把它放在哪里?
答案 0 :(得分:1)
试试这个:
$("li").each(function(){ // loop through all li
if($(this).hasClass("active")) { // check if li has active class
console.log($(this).data("interest")) // get the value of data-interest attribute
}
})
答案 1 :(得分:0)
试试这个:
var val = $('body').find('li.active').attr('data-interest');