如何将 id 添加到动态创建的 jquery 选项卡 [英] How to add the id to dynamically created jquery tab
本文介绍了如何将 id 添加到动态创建的 jquery 选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在创建动态 jQuery 选项卡.我想将 id 分配给每个选项卡.
I am creating dynamically jQuery tabs. I want to assign the id to each tab.
$("#addTab").live('click', function() {
index++;
var title = 'Tab..... ' + index;
var url = '#fragment-' + index;
addTab(url, title, index);
$('li[class=ui-state-default]').id(this)=1; // this line to add id
});
但 id 没有分配给选项卡..
but id is not assigning to the tab..
推荐答案
$('li.ui-state-default:last').attr('id', 'some_' + index); // only Numeric id not allowed
注意: $('li.ui-state-default').attr('id', 'some_' + index);
是更改所有 li 的 id有类 ui-state-default
,但当前代码只会改变最后一个的 id.
NOTE: $('li.ui-state-default').attr('id', 'some_' + index);
was change all li's id have class ui-state-default
, but current code will only change the last one's id.
这篇关于如何将 id 添加到动态创建的 jquery 选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文