小编mad*_*mar的帖子

在同一个div中包装标签和输入

我试图将我的radio输入和它包装label在一个单独div但不知何故它不包装输入.我的代码是:

HTML是:

<div class="payment_processor-section">
    <input id="input_0" class="form-radio" type="radio" checked="checked"  name="payment_processor" value="1">
    <label for="input_0">Credit Card</label>
    <input id="input_1" class="form-radio" type="radio" name="payment_processor" value="0">
    <label for="input_1" style="">I will send payment by check</label>
</div>
Run Code Online (Sandbox Code Playgroud)

我正在尝试的Jquery是:

$('.payment_processor-section input').map(function(index){
    $(this, $("label[for='"+this.id+"']") ).wrapAll('<div class="abc">');
});
Run Code Online (Sandbox Code Playgroud)

请帮忙.

html jquery jquery-selectors dom-traversal

4
推荐指数
2
解决办法
1400
查看次数

标签 统计

dom-traversal ×1

html ×1

jquery ×1

jquery-selectors ×1