2012-03-08 108 views
0

複選框的標籤文本是在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腳本您的建議。

回答

2

這個jQuery解決方案:

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

感謝diolaska得到它的工作! – expo101 2012-03-08 19:11:12

+0

您應該將其中一個答案標記爲已接受... – dioslaska 2012-03-13 11:32:12

0

既然你在你的問題提的jQuery:

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

一個PHP的解決方案會更好,但沒有任何代碼,我們不能幫你。

+0

感謝紀堯姆得到它的工作 – expo101 2012-03-08 19:10:53