2012-01-13 16 views
5

¿Cómo excluir la primera td en el evento click de jquery que creé a continuación? Quiero excluir todas las primeras td de las filas en el evento click que produce el cuadro de diálogo.Jquery excluye el primer evento td on click?

jQuery("#list tbody tr").click(function(){ 

//some code here 

}); 

<table> 
    <tr> 
     <td>first</td> 
     <td></td> 
     <td></td> 
    </tr> 
    <tr> 
     <td>first</td> 
     <td></td> 
     <td></td> 
    </tr> 
</table> 

Respuesta

13

Cómo sobre el uso del selector first-child combinado con :not:

jQuery("#list tbody tr td:not(:first-child)").click(function(){ 
    //some code here 
}); 

Ejemplo:http://jsfiddle.net/Rq8Xf/

+0

hay un error ... mis datos dependen de las filas de toda mi tabla. aquí http://intelaface.com/demo/lpc/products – kedomonzter

+0

@mocca: No estoy seguro de lo que quiere decir, ¿puede proporcionar más detalles? –

0
jQuery("#list tbody td").not(':first').click(function(){ 

    //some code here 

}); 
1
jQuery("#list tbody tr td:not(:first)") 
1
$('#list tr td:not(:first)').click(function() { 
    // ... 
}) 

por cierto. de donde sacaste a tbody? Además, su mesa necesita un id = "lista", por lo que:

<table id="list"> 
    <tr> 
     <td>first</td> 
     <td></td> 
     <td></td> 
    </tr> 
    <tr> 
     <td>first</td> 
     <td></td> 
     <td></td> 
    </tr> 
</table> 
2

probar esto,

jQuery("#list tbody tr").each(function() { 
    jQuery("td:not(:first)",this).click(function() { 
     alert($(this).text()); 
     //some code here 
    }); 
}); 

recuerde que está utilizando tbody en el html, así