[英]Jquery doesnt work on payment gateways woocommerce
I want to hide a div when an option is selected: 我想在选择选项时隐藏div:
jQuery(document).ready(function(){
if (jQuery('#Plaats').val() == "option_a") {
jQuery(".payment_method_cod").hide();
}
});
On this example, $payment_method_cod doesn't hide but if i change it to another div ID ( for example, #payment ) it works! 在此示例中,$ payment_method_cod不会隐藏,但是如果我将其更改为另一个div ID(例如#payment),它将起作用!
I hope someone can help me. 我希望有一个人可以帮助我。 Thanks in advance!
提前致谢!
There is a chance that other code might run which will result in not hiding the div you wanted. 其他代码可能会运行,从而导致您无法隐藏所需的div。 So what i would suggest is run this code the bottom of the site.
因此,我建议在网站底部运行此代码。
You can hook this code to the footer of the site using wp_footer
hook 您可以使用
wp_footer
钩子将此代码钩到站点的页脚
Comment or ask me if you have any doubts. 评论或询问我是否有任何疑问。
After Inspecting Questioner site. 在检查发问者站点之后。
Actually it is class
not id
. 其实这是
class
没有id
。 Please check it well. 请检查好。 So the code should be follows
因此代码应如下
jQuery('.payment_method_cod').hide();
Whole code is 整个代码是
jQuery(document).ready(function(){
if (jQuery('#Plaats').val() == "option_a") {
jQuery('.payment_method_cod').hide();
}
});
I think the script loaded to quick because the payment part of woocommerce is also done with jQuery. 我认为脚本加载很快,因为woocommerce的支付部分也使用jQuery完成。 After adding in the setTimeout() function it worked!
在添加setTimeout()函数后,它起作用了!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.