I am making dynamically jquery tabs and I want to assign the attribute onclick
to each tab.
$(function() {
var index = 0;
$("#addTab").live('click', function() {
index++;
var title = 'Tab..... ' + index;
var url = '#fragment-' + index;
$('#tabs').tabs("add", url, title, [index]);
$('li.ui-state-default').attr("onclick","a();"); // this line
});
but this is not working..
JS Fiddle http://jsfiddle.net/ranasaani/gP3YZ/18/
You could also use the builtin select event of the tab : http://jqueryui.com/demos/tabs/#event-select
$("#tabs").tabs({
select: function() {
// your code;
}
});
Working exemple : http://jsfiddle.net/cCN6H/