0
以下
を使用して周囲のテキストで入力をグループ化するために働いていないが、ラベルのタグが適切にはいそしてない要素のためのHTMLとスクリプトコードnextuntilはjQueryの
$('input[type=radio]').each(function(){
$(this).add(this.nextSibling).nextUntil('input').addBack().wrapAll('<label/>');
});
<div id="formelements">
<input type="radio"/> yes <br/>
<input type="radio"/> No <br/>
<input type="radio"/>Select <b>or</b> deselect<br/>
<input type="button" value="submit"/>
</div>
包まれています「選択または選択解除」のために適切にラベル付けされていません。下記の出力は、上記のコード
既存の出力用に生成されます。
<div id="formelements">
<label><input type="radio"> yes <br></label>
<label><input type="radio"> No <br></label>
<label><input type="radio">Select<b>or</b><br></label>deselect
<input type="button" value="submit">
</div>
必要な出力:
ここ<div id="formelements">
<label><input type="radio"> yes <br></label>
<label><input type="radio"> No <br></label>
<label><input type="radio">Select<b>or</b>deselect<br></label>
<input type="button" value="submit">
</div>
ありがとうございます – Manoj