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
});
but id is not assigning to the tab..
Hiya demo :) http://jsfiddle.net/gP3YZ/7/
code
should become
You use .attr method to set the attribute "id" to "1".
DEMO
NOTE:
$('li.ui-state-default').attr('id', 'some_' + index);
was change all li's id have classui-state-default
, but current code will only change the last one's id.