문제

The label text of a checkbox is dynamically generated in CodeCharge. The label text includes the amount of available articles. When this number is (0), the checkbox and the label text should be hidden, if not both checkbox and label value must be shown.

In this case checkbox and label text hidden:

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

In this case checkbox and label visible:

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

I appreciate your suggestions for a php or jquery script.

도움이 되었습니까?

해결책

A jQuery solution:

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

다른 팁

Since you mention jQuery in your question:

$(function() {
   $('input').filter(function() { return $(this).next('label').text().substr(-3) == '(0)'; }).hide().next('label').hide();
   });
});

A PHP solution would be better, but without any code, we cannot help you.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top