1
    var i1 = $("<input type='radio' class='11' value='11' /><input type='radio' class='2' value='2' />");
    var i2 = $("<input type='radio' class='111' value='111' /><input type='radio' class='12'  value='12' /><input type='radio' class='21' value='21' /><input type='radio' class='3' value='3' />");
    var i3 = $("<input type='radio' class='1111' value='1111' /><input type='radio' class='121'  value='121' /><input type='radio' class='13' value='13' /><input type='radio' class='31' value='31' /><input type='radio' class='22' value='22' /><input type='radio' class='4' value='4' />");
    var i4 = $("<input type='radio' class='11111' value='11111' /><input type='radio' class='122'  value='122' /><input type='radio' class='212' value='212' /><input type='radio' class='23' value='23' /><input type='radio' class='32' value='32' /><input type='radio' class='14' value='14' />");
    var i5 = $("<input type='radio' class='111111' value='111111' /><input type='radio' class='123'  value='123' /><input type='radio' class='132' value='132' /><input type='radio' class='213' value='213' /><input type='radio' class='222' value='222' /><input type='radio' class='33' value='33' /><input type='radio' class='24' value='24' />");
    b.append(i1);

我怎样才能使这个追加增量i1 i2 i3 i4 ...

我要点击第一个“+1”显示两个选项是i1。第二次点击“+1”显示i2。和 i3 i4 i5 i6...

并单击“-1”这个 i1.remove() i2 i3 删除...

并在“+1”之后上传/插入开关有问题..

对不起,我的英语不好。

这是一个工作小提琴

4

1 回答 1

4

将对象放在某个数组中并使用each循环遍历它们。

 var ix = [];
   ix.push( $("<input type='radio' class='11' value='11' /><input type='radio' class='2' value='2' />"));
   ix.push( $("<input type='radio' class='111' value='111' /><input type='radio' class='12'  value='12' /><input type='radio' class='21' value='21' /><input type='radio' class='3' value='3' />"));
   ix.push( $("<input type='radio' class='1111' value='1111' /><input type='radio' class='121'  value='121' /><input type='radio' class='13' value='13' /><input type='radio' class='31' value='31' /><input type='radio' class='22' value='22' /><input type='radio' class='4' value='4' />"));

$.each(ix, function(index, obj) { 
  b.append(obj);
});
于 2013-01-03T08:58:52.780 回答