$(document).ready(function() {
  $('#nav>li>a').click(function(event) {
    if ($(this).parent().children('ul').length) {
      event.preventDefault();
    }
  });
});
