jQuery('.annotax').tooltip({ content: function() { var id=jQuery(this).attr('id').split('__')[0]; return jQuery('.' + id + '_content').html(); } }); jQuery('.annotax').click(function() { var id=jQuery(this).attr('id').split('__')[0]; var id_t=id + '_content'; var id_w=id + '_widget'; var c=jQuery('.' + id_t).html(); c=''; if(jQuery('#' + id_w).length==0) { //append it if it does not exist jQuery( c ).hide().appendTo( "#ta_collection" ).show('normal'); } else { //animate it if it exists already jQuery('#' + id_w).fadeOut(40).fadeIn(40); } ta_counter(); });