Скрипт скрытия/раскрытия таблиц по клику на caption

JS Скрипт

$(document).ready(function(){
    $(".table_styles caption").parent().addClass('hide');
    $(".table_styles caption").click( function() {
                                $(this).parent().toggleClass('hide');  
                                                                                                                  });
})

CSS:

table {
  width: 100%;
}
.table_styles .hide thead,
.table_styles  .hide tbody{
  display:none;
}
.table_styles  table caption {
  cursor: pointer;
}