Woocommerce 2.6.2 添加禁用属性以更新购物车按钮 [英] Woocommerce 2.6.2 adds disabled attribute to update cart button
本文介绍了Woocommerce 2.6.2 添加禁用属性以更新购物车按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 Wordpress 4.5.3
和 Woocommerce 2.6.2
.
I am using Wordpress 4.5.3
and Woocommerce 2.6.2
.
woocommerce/cart/cart.php 中的代码
Code inside woocommerce/cart/cart.php
<input type="submit" class="button" id="update_cart_button" name="update_cart" value="<?php esc_attr_e( 'Update Cart', 'woocommerce' ); ?>" />
<?php do_action( 'woocommerce_cart_actions' ); ?>
<?php wp_nonce_field( 'woocommerce-cart' ); ?>
生成以下html:
<input type="submit" class="button" id="update_cart_button" name="update_cart" value="Winkelmand bijwerken" disabled="">
<input type="hidden" id="_wpnonce" name="_wpnonce" value="847e1da0f8">
<input type="hidden" name="_wp_http_referer" value="/winkelmand/">
所以奇怪的是,在输入字段中添加了禁用"属性.当我使用开发人员工具删除禁用值时,我可以单击按钮并正确更新购物车.
So the strange thing is that inside the input field the 'disabled' attribute is added. When i remove the disabled value with developer tools i can click the button and the cart is updated correctly.
所以我想删除这个属性,我已经尝试过:
So i want to remove this attribute, what i have tried:
尝试 1
<script>
document.getElementById('update_cart_button').disabled = false;
</script>
尝试 2
<script>
jQuery('#update_cart_button').prop('disabled', false);
</script>
尝试 3
<script>
jQuery('#update_cart_button').removeAttr('disabled');
</script>
但没有一个解决方案删除禁用属性.
but none of the solutions remove the disabled attribute.
推荐答案
你可以试试下面的代码-
You can try below code-
jQuery(document).ready(function() {
jQuery( '.shop_table.cart' ).closest( 'form' ).find( 'input[name="update_cart"]' ).removeProp( 'disabled');
});
这篇关于Woocommerce 2.6.2 添加禁用属性以更新购物车按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文