通过此功能,我可以更改“付款”按钮上的文字。 我想插入一个小图像。
./src/assets/tshirt/gitF/tshirt.glb 1:4
Module parse failed: Unexpected character '' (1:4)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)
提前感谢您的帮助!
答案 0 :(得分:2)
与前端一样,按钮文本将通过使用jQuery的.text()
函数进行更改,在此处无法添加类似img标签的html。
我建议您将javascript与jQuery结合使用。应该是这样的:
$( document.body ).on( 'payment_method_selected', function(){
var selectedPaymentMethod = $( '.woocommerce-checkout input[name="payment_method"]:checked' ).attr( 'id' );
$( '#place_order' ).find('.payment-icon');
$( '#place_order' ).prepend('<span class="payment-icon '+ selectedPaymentMethod +'"></span>'); // or any element like from font-awesome.
});
$( document.body ).trigger( 'payment_method_selected' ); // this will trigger on page load, act as initialize the icon.
上面的脚本将添加一个span
标签,该标签带有类payment-icon
和所选付款方式的ID。然后,您可以使用CSS在此范围内将图标添加为背景。