jquery - select dynamic tab immediately upon new tab creation -
demo : http://jsfiddle.net/axrwkr/ujuu2/
var num_tabs = $("div#tabs ul li").length + 1; $("div#tabs ul").append( "<li><a href='#tab" + num_tabs + "'>#" + num_tabs + "</a></li>" ); $("div#tabs").append( "<div id='tab" + num_tabs + "'>#" + num_tabs + "</div>" ); $("div#tabs").tabs("refresh");
the new tabs syntax complicated (after 1.9 upgrade)..
one more question, 1.9 onward remove method had been depreceated, if want remove particular tab, should use remove() remove tab element , appended div (content)? sound un-practical..
add in end of $("button#add-tab").click(function()
$('a[href=#tab'+num_tabs+']').click(); //click new tab link make active
or can use active
option
$("div#tabs").tabs("refresh").tabs({ active:num_tabs - 1});
Comments
Post a Comment