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>
当我使上面的代码文本,标签标签被适当地包装为Yes和No元素但它没有正确标记为“选择或取消选择”。下面是上述代码
现有输出生成的输出:
<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