我正在使用Oracle CPQ工具,我正在尝试创建一个复选框作为属性。
在UI中我得到以下内容:
在浏览器源(由CPQ工具生成)中查看时,我可以看到以下HTML代码:
<div class="form-item clearfix null" id="attr_wrapper_1_chkmembershipFeePayment_t" style="display: table;">
<label class="form-label" for="chkmembershipFeePayment_t" style="width: 100px">
<span style="padding-right: 5px;display: table-cell;">Membership Fee</span>
</label>
<div class="form-element field-wrapper" id="field_wrapper_1_chkmembershipFeePayment_t" style="padding-left:100px">
<div class="boolean-wrapper field" message="" style="display: table-cell;">
<div class="boolean-wrapper-inner"><input value="false" class=" form-input cm-attr-value " name="chkmembershipFeePayment_t" onclick="if (this.checked) { this.value='true'; } else { this.value='false'; }" data-is-boolean="true" type="checkbox">
</div>
<input value="true" name="_boolean_present_chkmembershipFeePayment_t" type="hidden">
</div>
<div id="msg_1_chkmembershipFeePayment_t" class="error-hover" data-action-message="" message=""></div>
</div>
::after</div>
我的问题是:我如何切换复选框和标签,使用CSS或JavaScript将标签'标签'免费会员'放在之前,考虑到我无法使用CPQ工具直接编辑HTML属性。
那么有没有办法呢?
Sagar V之后更新了javascript
答案 0 :(得分:2)
elm = document.querySelector('label[for=chkmembershipFeePayment_t]');
target = document.querySelector("input[type=checkbox]");
elm.parentNode.removeChild(elm);
target.parentNode.insertBefore(elm, target.nextSibling);
&#13;
<label class="form-label" for="chkmembershipFeePayment_t" style="width: 100px">
<span style="padding-right: 5px">Membership Fee</span>
</label>
<div class="form-element field-wrapper" id="field_wrapper_1_chkmembershipFeePayment_t" style="padding-left:100px">
<div class="boolean-wrapper field" message="">
<div class="boolean-wrapper-inner">
<input value="false" class=" form-input cm-attr-value " name="chkmembershipFeePayment_t" onclick="if (this.checked) { this.value='true'; } else { this.value='false'; }" data-is-boolean="true" type="checkbox">
</div>
<input value="true" name="_boolean_present_chkmembershipFeePayment_t" type="hidden">
</div>
<div id="msg_1_chkmembershipFeePayment_t" class="error-hover" data-action-message="" message=""></div>
&#13;