javascript - 选择其他运输方式时隐藏元素
问题描述
I tried to add a checkbox for a pick-up shipping method, so when the method is chosen, the tickbox appears and need to be validated but when the other shipping method is chosen, I want it to disappear. 当前,它没有得到验证,选择其他选项时,它都不会消失(主要问题)。
基于在 WooCommerce 3 答案中的特定运输方式下方添加复选框,这是我正在使用的代码:
add_action( 'woocommerce_after_shipping_rate', 'checkout_shipping_additional_field', 20, 2 );
function checkout_shipping_additional_field( $method, $index )
{
if( $method->get_id() == 'pickup-location-method' ){
echo '<br>
<input type="checkbox" name="shipping_custom_1" id="shipping_custom_1" value="1" class="shipping_method shipping_custom_1">
<label for="shipping_custom_1">I confirm that I'll attend the delivery.</label>';
}
}
不幸的是,我有限的知识不允许我进一步使用此代码。你能帮我解决这个问题吗?
解决方案
推荐阅读
- c++ - SDL2如何在窗口调整大小后缩放鼠标坐标?
- ssh - 无法在 gitlab 中使用 ssh 对远程 vps 进行身份验证
- python - mac 错误 20 在 0 深度查找:无法获取本地颁发者证书
- java - JFrame 默认关闭操作中可能出现的故障
- android - Shell 脚本等待命令永远不会结束
- c# - Newtonsoft.Json.Jobject.parse:未终止的字符串。预期的分隔符位置 32767
- jquery - 具有匹配字符串的 jQuery 选择属性
- python - urdu 字符串看起来相同,但相比之下发现不相等的 python3
- python - 从 JSON 获取服务器 ID
- java - 防止过多的注册请求