Change color of a cell?

1

I have a table in which I print several data, but I want that in the cell, state, when waiting for it to be of one color, and to be approved, of another.

Try jQuery but at the moment it has not worked for me.

<!--
.estado1 {background-color : #ffff99; }
.estado2 {background-color : #00ffff; } --> 
</style>
<table class="table table-responsive">
    <tr class="success">
        <th>No de Deposito</th>
        <th>No de Comprobante</th>
        <th>Monto</th>
        <th>Banco</th>
        <th>Tipo de Transacción</th>
        <th>Fecha de Comprobante</th>
        <th>Detalles</th>
        <th>Observaciones</th>
        <th>Fecha de Solicitud de Autorización</th>
        <th>Estado</th>
        <th>Fecha de Autorización</th>
    </tr>

@foreach($depositos as $deposito)
<tr>
    <td>{{ $deposito->id}}</td>
    <td>{{ $deposito->noboleta}}</td>
    <td>{{ $deposito->monto}}</td>
    <td>{{ $deposito->banco->nombre}}</td>
    <td>{{ $deposito->tipo->tipo}}</td>
    <td>{{ $deposito->fechaboleta}}</td>
    <td>{{ $deposito->detalles}}</td>
    <td>{{ $deposito->observaciones}}</td>
    <td>{{ $deposito->created_at}}</td>
    <td>{{ $deposito->estado->estado}}</td>
    <td>{{ $deposito->updated_at}}</td>
    <td>

    </td>
</tr>
@endforeach
</table>
<script src=”http://code.jquery.com/jquery-1.11.1.min.js” type=”text/javascript”></script>
 <script type=”text/javascript>
$(document).ready(function() {
   $('td:contains(“espera”)').addclass('estado1');
   $('td:contains(“aprobado”)').addclass('estado2');
});

    
asked by JoséOrdoñez 06.12.2017 в 17:12
source

1 answer

0

What you could do is create a condition within the same structure using the tools provided by blade .

To make sure that your styles are priority over others you could use !important or you could use classes that Bootstrap brings by default .info or .danger

<style>
  .estado1 {background-color : #ffff99 !important; }
  .estado2 {background-color : #00ffff !important; }
</style>

<table class="table table-responsive">
    <tr class="success">
        <th>No de Deposito</th>
        <th>No de Comprobante</th>
        <th>Monto</th>
        <th>Banco</th>
        <th>Tipo de Transacción</th>
        <th>Fecha de Comprobante</th>
        <th>Detalles</th>
        <th>Observaciones</th>
        <th>Fecha de Solicitud de Autorización</th>
        <th>Estado</th>
        <th>Fecha de Autorización</th>
    </tr>

@foreach($depositos as $deposito)
<tr>
    <td>{{ $deposito->id}}</td>
    <td>{{ $deposito->noboleta}}</td>
    <td>{{ $deposito->monto}}</td>
    <td>{{ $deposito->banco->nombre}}</td>
    <td>{{ $deposito->tipo->tipo}}</td>
    <td>{{ $deposito->fechaboleta}}</td>
    <td>{{ $deposito->detalles}}</td>
    <td>{{ $deposito->observaciones}}</td>
    <td>{{ $deposito->created_at}}</td>
    @if($deposito->estado->estado == 'espera')
      <td class="estado1">{{ $deposito->estado->estado}}</td>
    @elseif($deposito->estado->estado == 'aprobado')
      <td class="estado2">{{ $deposito->estado->estado}}</td>
    @endif
    <td>{{ $deposito->updated_at}}</td>
    <td>

    </td>
</tr>
@endforeach
</table>
    
answered by 06.12.2017 / 17:50
source