Jquery 如何选择当前的DIV类

Jquery 如何选择当前的DIV类,jquery,jquery-ui,class,html,Jquery,Jquery Ui,Class,Html,我通过选择类将唯一ID分配给div $("#addTab").live('click', function() { index++; var title = 'Tab..... ' + index; var url = '#fragment-' + index; addTab(url, title, index); $('li.ui-state-default:last').attr("id",index); // How I can get the

我通过选择类将唯一ID分配给
div

$("#addTab").live('click', function() {
    index++;
    var title = 'Tab.....  ' + index;
    var url = '#fragment-' + index;

    addTab(url, title, index);
    $('li.ui-state-default:last').attr("id",index); // How I can get the current class??

});
但我想将这些ID分配给当前选项卡。因为最后一个选项卡没有获取id

JS小提琴:

每个选择的选项卡都有类
ui选择
ui状态焦点
ui状态活动

所以你可以像这样上课

$('li.ui-selected').attr('class');
要获取新添加选项卡的类别,请尝试:

var ref = $('li.ui-state-default:last').attr("id",index); 
alert($(ref).attr('class'));

我想选择当前类别当前为活动类别,对吗?不,不需要。。因为选项卡是基于数据库中的数据创建的,我想在那个时候通过它们的类别为每个选项卡分配一个唯一的id。它更改了整个选项卡的idclass@RanaSaani要将id分配给所选选项卡还是新添加的选项卡?
var ref = $('li.ui-state-default:last').attr("id",index); 
alert($(ref).attr('class'));