jQuery将动态创建的列表放入<;ul>;标签
jQuery将动态创建的列表放入<;ul>;标签,jquery,list,append,Jquery,List,Append,.append()。 我该怎么做 (为每个问题生成的fullQuestion只是一个) 函数writeQuestions(){ $(“#容器”)。追加(“\n”); len=questions.qestion.length; 对于(变量i=0;i
.append()。
我该怎么做
(为每个问题生成的fullQuestion
只是一个
)
函数writeQuestions(){
$(“#容器”)。追加(“\n”);
len=questions.qestion.length;
对于(变量i=0;i `- `\n\n”).format(divID、formID、CurrentForm);
writeAnswer[writeAnswer.length]=(“+qestionRdy+”
\n”);
对于(var n=0;n尝试此操作,它应该在ul中插入fullQuestion字符串
$('#container ul').html(fullQuestion);您没有正确使用append
首先创建一个UL
var $ul = $('<ul>');
$('#container').append($ul);
//all other code
$ul.append(fullQuestion);
var$ul=$(“”);
$('#container')。追加($ul);
//所有其他代码
$ul.附加(完整问题);
并删除此行$(“#container”)。追加(“\n
”;
var $ul = $('<ul>');
$('#container').append($ul);
//all other code
$ul.append(fullQuestion);