tbody'); var $tr = $("

不过,我想 $ noofanswers 将包含在它自己的表行,所以我再改 $ noofanswers 包括< TR>< / TR> 使code:

But I wanted $noofanswers to be included in it's own table row so I then change $noofanswers to include <tr></tr> so that code:

var $noofanswers = $("<td class='noofanswers'></td>");

现在变成了:

var $noofanswers = $("<tr><td class='noofanswers'></td></tr>");

但是,如果我这样做,那么 $('。numberAnswerTxt,背景)。每个(函数(){不正确不是那么回事。所以我的问题是,如果我添加了&LT; TR&GT; 标签,那什么,我需要在函数中改变让它再次合作

But if I do this then $('.numberAnswerTxt', context).each(function() { doesn't quite work correctly. So my question is that if I add the <tr> tags, then what do I need to change within the function to get it working again?

推荐答案

insertQuestion 功能已经包装了 D 在元素 TR

The insertQuestion function already wraps the td element in a tr:

var $tr = $("<tr class='optionAndAnswer' align='center'></tr>");
//...
$tr.append($noofanswers);

您可以简单地修改 TR $ TR ,而不是增加 $ noofanswers ,或者你可以删除调用追加并保持 TR $ noofanswers

You could simply modify $tr instead of adding the tr to $noofanswers, or you could remove the call to append and keep the tr in $noofanswers.

//var $tr = $("<tr class='optionAndAnswer' align='center'></tr>");
var $noofanswers = $("<tr><td class='noofanswers'></td></tr>");
//...
//$tr.append($noofanswers);
$tbody.append($noofanswers); 
阅读全文

相关推荐

最新文章