嗨演示:) http://jsfiddle.net/gP3YZ/7/
代码
$(document).ready(function() {
$("#tabs").tabs({
tabTemplate: "<li><a href='#{href}'>#{label}</a> <p title='close' id='removeTab' style='cursor:pointer;display:inline'>x</p></li>"
});
});
$(function() {
var index = 0;
$("#addTab").live('click', function() {
index++;
var title = 'Tab..... ' + index;
var url = '#fragment-' + index;
addTab(url, title, index);
$('li.ui-state-default').attr("id","1");
alert($('li.ui-state-default').attr("id"));
});
function addTab(url, title, index) {
$('#tabs').tabs("add", url, title, [index]);
}
$('#removeTab').live('click', function() {
selected = $('p[id=removeTab]').index(this); // this line to add id
$('#tabs').tabs("remove", [selected]);
});
$('#appendText').live('click', function() {
$('#tabs .ui-tabs-panel').each(function(index) {
if(!($(this).hasClass('ui-tabs-hide'))){
//do the dew!
$(this).append("Bla Bla!!!");
}
});
});
});