How to operate jQuery object correctly?
$('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();
精彩评论