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」をクリックして、2 つのオプションが i1 であることを表示します。2 回目の「+1」をクリックすると、i2 が表示されます。と i3 i4 i5 i6...

「-1」この i1.remove() i2 i3 remove... をクリックします。

「+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 に答える