开发者

How to operate jQuery object correctly?

开发者 https://www.devze.com 2022-12-13 07:21 出处:网络
$(\'table.diyform\').children(\'tbody\').children(\'tr\').each(function() { var $tds = $(this).children(\'td\');
$('table.diyform').children('tbody').children('tr').each(function() {
    var $tds = $(this).children('td');
    var label = $tds[0].find('a').html();
    var required = $tds[0].find('input').html(开发者_Python百科);
});

The problem lies in $tds[0] but I don't know the correct way to do it yet.


You will need to use eq.

$('table.diyform').children('tbody').children('tr').each(function() {
        var $tds = $(this).children('td');
        var label = $tds.eq(0).find('a').html();
        var required = $tds.eq(0).find('input').html();
});


Try:

var tds = $(this).children('td');
var label = $(tds).find('a').html();
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号