<ul class="nav nav-tabs" style="border-bottom:1px #000 solid;">
  @foreach ($datos as $var)
    @if ($var->MZ == 1)
      <li class="nav-item">
        <a class="nav-link" id="mz" style="border-bottom:1px #000 solid;" data-toggle="tab">Manzanillo</a>
      </li>
    @endif
    @if ($var->LZ == 1)
      <li class="nav-item">
        <a class="nav-link" id="lz" style="border-bottom:1px #000 solid;" data-toggle="tab">Lázaro cárdenas</a>
      </li>
    @endif
    @if ($var->VZ == 1)
      <li class="nav-item">
          <a class="nav-link" id="vz" style="border-bottom:1px #000 solid;" data-toggle="tab">Veracruz</a>
      </li>
    @endif
    @if ($var->MX == 1)
      <li class="nav-item">
          <a class="nav-link" id="mx" style="border-bottom:1px #000 solid;" data-toggle="tab">México</a>
      </li> 
    @endif
  @endforeach
  @foreach ($datos as $var)
    <input type="hidden" value="{{$var->ubicacion}}" id="ubicacionid">
  @endforeach
</ul>

<script>
  $(document).ready(function(){
    var val = $('#ubicacionid').val();

    if(val == "manzanillo"){
      $('#mz').addClass('active');
    }

    if(val == "lazaro"){
      $('#lz').addClass('active');
    }

    if(val == "veracruz"){
      $('#vz').addClass('active');
    }

    if(val == "mexico"){
      $('#mx').addClass('active');
    }
  });
</script>