我有一个这样的 HTML:
<dl>
<dt class="tab-title">Title</dt>
<dd class="tab-content">Ain't Life Grand</dd>
</dl>
JS 之后的最终 HTML 需要如下所示:
<dl>
<dt class="tab-title">Title</dt>
<dd class="tab-content">Ain't Life Grand</dd>
<dt class="tab-title">Another Title</dt>
<dd class="tab-content">Ain't Life Grand again</dd>
<dt class="tab-title">How'about Another</dt>
<dd class="tab-content">Ain't Life Grand last!</dd>
</dl>
我到目前为止的JS如下:
<script type="text/javascript">
var arrayData = {
titletwo: {
title: 'Another Title',
html: 'Ain\'t Life Grand again'
},
titlethree: {
title: 'How\'about Another',
html: 'Ain\'t Life Grand last!'
}
}
for (var key in arrayData) {
var obj = arrayData[key];
$$('dl').insert('<dt class="tab-title">'.obj['title'].'</dt>');
$$('dl').insert('<dd class="tab-content">'.obj['title'].'</dd>');
}
</script>
它似乎没有做任何事情。请投稿!