在Safari中隐藏选择选项标签

时间:2020-09-30 14:28:31

标签: html jquery wordpress woocommerce safari

WordPress woocommerce网站上的休闲jquery出现问题。它会从chrome / Opera / IE / Firefox中的索引中删除所需的标签,但在Safari中不起作用。仍然奇怪的是,当我将jQuery输入Safari的浏览器检查器>控制台时,代码将执行/返回并删除正确的选项标签。在WordPress中使用DIVI主题,并且将jQuery放在WP管理面板>主题选项>集成头代码注入窗口中。

另外,为了清楚起见,我有一条if(window.location.href.indexOf()条件语句,因为我希望代码仅在站点的特定页面上执行。

jQuery(document).ready(function($) {
    if(window.location.href.indexOf("Insert URL string") >= 0) {
        $('#dehumidifier-hanger-size option[value="Large (Fits 1870 model)"]').prop('selected', 'selected').remove();
    };
});
<select id="dehumidifier-hanger-size" class="" name="wccp_attribute_dehumidifier-hanger-size[1597339203]" data-attribute_name="attribute_dehumidifier-hanger-size" data-show_option_none="yes">
  <option value="">Choose an option</option>
  <option value="Regular (Fits 1820,1830,1850 models)" class="attached enabled">Regular (Fits 1820,1830,1850 models)</option>
  <option value="Large (Fits 1870 model)" class="attached enabled">Large (Fits 1870 model)</option>
</select>

0 个答案:

没有答案
相关问题