how to get columns in one row using jquery

2019-08-05 03:21发布

I am trying to get columns inside row. But I only want to get those columns who does not have class element. How can I do this?

Code:

update_data: function() {
    $('#add').click(function() {
        var uid = $('input[name="id"]').val();
        var fname = $('input[name="firstname"]').val();
        var lname = $('input[name="lastname"]').val();
        var email = $('input[name="email"]').val();
        var phone = $('input[name="phone"]').val();

        var table_rows = $('table tbody tr');

        table_rows.each(function(i) {

            if (i == uid - 1) {
                var tr = $(this); //.children("td");                                
                $(tr).each(function(i) {
                    if (!tr.children("td").hasClass("element")) {
                        console.log(tr.children("td"));
                    }
                });
            }
        });
    });
}​

4条回答
我命由我不由天
2楼-- · 2019-08-05 03:37

I think this will done your job

$('td:not(".element")', tr)
查看更多
迷人小祖宗
3楼-- · 2019-08-05 03:44
$(tr).find('td:not(".element")')...

Or:

$(this).children('td:not(".element")')...

With all the rows:

$('table tbody tr td:not(".element")');
查看更多
SAY GOODBYE
4楼-- · 2019-08-05 03:49

You can select all cells, that does not have the "element" class, with this selector:

$('td').not('.element')
查看更多
Bombasti
5楼-- · 2019-08-05 03:55

Just use this selector. It will select all td which has not element class

$('table td:not(.element)')
查看更多
登录 后发表回答