2 回答
TA贡献1785条经验 获得超8个赞
为了实现这一点,您可以使用wrapAll函数。
简单地说:$(".button-column").wrapAll("<div class='button-row'></div>")
; `
TA贡献1796条经验 获得超7个赞
调用wrap()添加.button-column元素后,调用wrapAll()将所有这些元素包装在.button-row:
$('.simpay-form-control.simpay-radio-container').wrap('<div class="button-column" />');
$('.simpay-form-control.simpay-custom-amount-container').wrap('<div class="button-column" />');
$('.button-column').wrapAll('<div class="button-row" />');
.button-column {
border: 1px solid #CCC;
margin: 5px;
padding: 5px;
}
.button-row {
border: 1px solid #C00;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form action="" method="post" class="simpay-checkout-form simpay-form-12345
simpay-styled simpay-checkout-form--embedded" id="simpay-form-12345" data-simpay-form-id="12345">
<div class="simpay-form-control simpay-radio-container">Foo</div>
<div class="simpay-form-control simpay-custom-amount-container">Bar</div>
</form>
添加回答
举报