javascript bootstrap ontab change

JavaScript
 $('.nav-tabs a').on('shown.bs.tab', function(event){
  var x = $(event.target).text();         // active tab
  var y = $(event.relatedTarget).text();  // previous tab
}); 
Source

Also in JavaScript: