【问题标题】:Hide Checkbox and Label based on Label text根据标签文本隐藏复选框和标签
【发布时间】:2012-03-08 12:14:10
【问题描述】:

复选框的标签文本在 CodeCharge 中动态生成。标签文本包括可用文章的数量。当此数字为 (0) 时,应隐藏复选框和标签文本,否则必须显示复选框和标签值。

在这种情况下,复选框和标签文本隐藏:

<input id="i_search_2_newdatad9_1" name="d9[]" value="standplaatsreis" type="checkbox"  /><label for="i_search_2_newdatad9_1">Standplaatsreis (0)</label>

在这种情况下,复选框和标签可见:

<input id="i_search_2_newdatad9_1" name="d9[]" value="standplaatsreis" type="checkbox"  /><label for="i_search_2_newdatad9_1">Standplaatsreis (8)</label>

感谢您对 php 或 jquery 脚本的建议。

【问题讨论】:

    标签: php jquery codecharge


    【解决方案1】:

    一个jQuery解决方案:

    $('label:contains("(0)")').each(function() {
        $('#' + $(this).attr('for')).hide();
        $(this).hide();
    });
    

    【讨论】:

      【解决方案2】:

      既然您在问题中提到了 jQuery:

      $(函数(){ $('input').filter(function() { return $(this).next('label').text().substr(-3) == '(0)'; }).hide()。下一个('标签').hide(); }); });

      PHP 解决方案会更好,但没有任何代码,我们无法为您提供帮助。

      【讨论】:

        猜你喜欢
        • 2017-04-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-10-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多