I'm using this Javascript script to display a list of Youtube channels related to a specific topic when this is chosen by the user, but if I click again on the name of the topic, its tab does not collapse. Instead it again shows the list of channels.
var channels=[
{ id:1, name:"Example 1", description:"", videos:[]},
{ id:2, name:"Example 2", description:"", videos:[]},
];
jQuery(function() {
jQuery("#tabs").tabs();
listChannels();
});
function listChannels(){
jQuery(channels).each(function(i,channel){
jQuery("#listOfChannels").append("<li id='channel"+channel.id+"'><span onclick='showChannel("+channel.id+")'>> "+channel.name+"</span><div id='videos"+channel.id+"' class='contentChannel'></div></li>");
});
}