JQuery exclude first td on click event?

How to exclude the first td on the jquery click event that I created below? I want to exclude all the first td lines in the click event that creates the dialog box.

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>
+5
source share
5 answers

How to use the selector first-childin combination with :not:

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

Example: http://jsfiddle.net/Rq8Xf/

+13
source

try it,

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

remember that you use tbody in html as well

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

by the way. where did you come from In addition, your table needs id = "list", therefore:

<table id="list">
    <tr>
        <td>first</td>
        <td></td>
        <td></td>
    </tr>
    <tr>
        <td>first</td>
        <td></td>
        <td></td>
    </tr>
</table>
+1
source
jQuery("#list tbody td").not(':first').click(function(){

    //some code here

});
0
source

All Articles