我正在尝试从我的旧站点中提取旧的常见问题解答系统并将其重新编码为<dl>
.
到目前为止,这是我的 jQuery 代码:
$accordion = $('.accordion');
$headers = $accordion.find('h3.trigger-h3-accordion a');
$content = $accordion.find('div.toggle-accordion-large');
out = "<dl>\n";
$headers.each(function(k,v) {
out += "<dt>" + $(this).text() + "</dt>\n";
out += "<dd>" + $content[k].html() + "</dd>\n";
// I also tried $content.k.html() and $content{k}.html()
// and .text() on all of those options
});
out += "</dl>\n";
console.log(out);
我得到错误:TypeError: $content[k].html is not a function
在线的:out += "<dd>" + $content[k].html() + "</dd>\n";
<div class="accordion">
<div class="trigger-accordion-large trigger-accordion-active">
<h3 class="trigger-h3-accordion"><a href="#" onclick="return stopAccordionRefresh();">Header Text</a></h3>
</div>
<div style="display: block;" class="toggle-accordion-large">
<div class="block-large">
<div class="body-content-textarea">
<p>Content Text.</p>
</div>
</div>
</div>
</div>
如何输出循环中每个 $content 对象的内容以创建<dl><dt><dd>
我所追求的有效内容?