我正在使用以下脚本替换来自店面/购物插件的短代码提供的一些文本。如果您将商品添加到购物车并转到结帐,您可以看到以下内容。
pcos_eddiscountcode = function () {
var pcos_edd_discount_code = jQuery('#edd_discount_code').html();
var new_pcos_edd_discount_code = pcos_edd_discount_code.replace('Click to enter it', 'Click here to enter it');
jQuery('#edd_discount_code').html(new_pcos_edd_discount_code);
};
工作得很好,但它会在插件的一个完全独立的部分引起问题。你可以在here (add to cart buttons are ignoring my css and forcing a page redirect on click).上看到它
我收到以下错误:
TypeError: undefined is not an object (evaluating 'pcos_edd_discount_code.replace')
我对javascript完全是个新手,所以任何其他的我都会很感激!
:)
https://stackoverflow.com/questions/47585579
复制相似问题