[英]Why isn't my JQuery/CSS code working when I import it into my Wordpress website?
[英]why my jQuery is not working when i am uploading on the website
当我在控制台上编写代码时,它可以正常工作。 当我在网站上上传时,它不起作用。
我想做一个条纹卡详细信息字段验证。 填写详细信息时,填充框的边框颜色应与卡片详细信息相同
我试过的代码:
if (jQuery('.input-text.wc-credit-card-form-card-expiry').val() == '') {
jQuery('.input-text.wc-credit-card-form-card-expiry').css('border-color', 'red');
}
else {
jQuery('.input-text.wc-credit-card-form-card-expiry').css('border-color', 'green');
}
网页网址: https : //www.preprod.swett.se/checkout-2/
如果您在网站上查看。 卡号字段工作正常。 我希望到期日期和 cvv 字段日期也应该与卡片详细信息相同
你能帮我这个jQuery吗?
试试这个,看看它是否有效,请确保包含jQuery
:
jQuery('#stripe-card-expiry').on('keyup', function(){
var $input = jQuery(this);
$input.css('border-color', !$input.val() ? 'red' : 'green');
});
由于此代码,卡号字段工作正常
jQuery('#stripe-card-number').on('keyup', function ($) {
if (jQuery(this).val().length > 0) {
jQuery('#stripe-card-number').css('border', '2px solid #69bf29');
}
});
因此,类似地,您需要在 keyup 事件上触发代码以获取到期日期和 cvv
jQuery('.wc-credit-card-form-card-expiry').on('keyup', function ($) {
if (jQuery('.input-text.wc-credit-card-form-card-expiry').val() == '') {
jQuery('.input-text.wc-credit-card-form-card-expiry').css('border-color', 'red');
}
else {
jQuery('.input-text.wc-credit-card-form-card-expiry').css('border-color', 'green');
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.