Set as active next or previous submenu

Set as active next or previous submenu

I'm working with this jSFiddle: https://jsfiddle.net/vkuz8ra3/

And i need function which active next or previous link after click to div prev or div next.

I tried something like this but it does not work

  1. jQuery(document).ready(function($) {   
  2.  $('.prev').click(function() {
  3.       $('#links').children().prev().addClass('active');
  4.  var index = $('#links').children().index('#links');
  5.       $('#linksobsah').children().hide(500).eq(index).show(500);               
  6. $('#links').children().removeClass('active');
  7.       $('#links').addClass('active'); 
  8.     });
  9. });

I would be grateful if someone can help me Thank you :)