Ver Mensaje Individual
  #1 (permalink)  
Antiguo 12/01/2014, 13:44
Avatar de satjaen
satjaen
 
Fecha de Ingreso: septiembre-2012
Ubicación: Jaén (Andalucía)
Mensajes: 893
Antigüedad: 11 años, 8 meses
Puntos: 10
Añadir estilo a unas filas.

Hola, por favor quería saber si puedo darle estilo a una fila del siguiente código:

Código Javascript:
Ver original
  1. function filtrar(){
  2.  
  3. $.ajax({
  4. data: $("#frm_filtro").serialize()+ordenar,
  5. type: "POST",
  6. dataType: "json",
  7. url: "ajax.php?action=listar",
  8. beforeSend:function(){
  9. $('.carga1').css('display','block');
  10. $('.carga1').html("<img src='imagenes_menu/ajax-loader4.gif' align='center' /><br />Cargando...");
  11.     },  
  12. complete: function() {
  13.  
  14. $(".carga1").show();
  15. $(".carga1").hide();
  16.  
  17.     },
  18.  success: function(data){
  19.  var html_user ='' ;
  20.  if(data.length > 0){
  21.  $.each(data, function(i,item){
  22.  
  23. html_user += '<tr onclick="pulsar1(this, ' + *String.fromCharCode(39) + item.id_aviso + String.fromCharCode(39) *+ ');"     ondblclick="pulsar(this, ' +  String.fromCharCode(39) + item.id_aviso + String.fromCharCode(39) *+ ');" >';
  24. html_user += '<td><input name="demo" type="checkbox" value="' + item.id_aviso + '"/></td>';
  25.  html_user += '<td>'+item.id_aviso+'</td>';
  26.  html_user += '<td>'+item.telefonos+'</td>';
  27.  html_user += '<td>'+item.name+' '+item.apellidos+'</td>';
  28.  html_user += '<td>'+item.calle+'</td>';
  29.  html_user += '<td>'+item.localidad+'</td>';
  30.  html_user += '<td>'+item.aparatos+'</td>';
  31.  html_user += '<td>'+item.marcas+'</td>';
  32.  html_user += '<td>'+item.facturacion+'</td>';
  33.  html_user += '</tr>';
  34.  
  35.  
  36.      });
  37.   }
  38.  
  39.  if(html_user == '')
  40.     html_user = '<tr><td colspan="4" align="center">No se encontraron registros..</td></tr>';
  41. $("#data tbody").html(html_user);
  42. $('.carga').html('');

Tengo que aclarar que lo que quiero es cambiar el estilo de la fila dependiendo de el valor del item recibido. Es decir si por ejemplo el valor del item facturacion es igual a 1 cambiar el color de la fila a color rojo.



Gracias un saludo

Última edición por satjaen; 12/01/2014 a las 15:32