我正在创建八个 div,我希望使用这些 div 类将它们附加到一个和一个到八个其他 div:
var foo1 = "<span class='fooClass'>Foo text1</span>";
var foo2 = "<span class='fooClass'>Foo text2</span>";
var foo3 = "<span class='fooClass'>Foo text3</span>";
var foo4 = "<span class='fooClass'>Foo text4</span>";
var foo5 = "<span class='fooClass'>Foo text5</span>";
var foo6 = "<span class='fooClass'>Foo text6</span>";
var foo7 = "<span class='fooClass'>Foo text7</span>";
var foo8 = "<span class='fooClass'>Foo text8</span>";
$('.fooData').each(function(i) {
$('this').append('foo' + i);
});
.fooData div(同样,其中也有八个)是在创建我要附加的 div 之前创建的。
然而这不起作用(即没有数据被添加到.fooData-divs)。我究竟做错了什么?
注意:如果重要,.fooData-divs 也有其他类,例如:
<div class="color4 fooData leftSide"></div>