使用jquery隐藏文本

时间:2012-07-13 01:33:17

标签: php javascript jquery html css

我有这个清单

<li id="field_7_div" class="field_block">
<div class="col_label">
<label class="form_field">How satisfied are you with <span class="aggregator_name">your aggregator</span>?</label>
<label class="form_required">*</label>
</div>
<div class="col_field">
<div class="radio" id="uniform-field_7_0"><span>
<input type="radio" class="form_radio" value="Very Satisfied" id="field_7_0" name="field_7" style="opacity: 0;">
</span></div>
<label for="field_7_0" class="form_choice_text">Very Satisfied</label>
<br>
<div class="radio" id="uniform-field_7_1"><span>
<input type="radio" class="form_radio" value="Satisfied" id="field_7_1" name="field_7" style="opacity: 0;">
</span></div>
<label for="field_7_1" class="form_choice_text">Satisfied</label>
<br>
<div class="radio" id="uniform-field_7_2"><span>
<input type="radio" class="form_radio" value="Neutral" id="field_7_2" name="field_7" style="opacity: 0;">
</span></div>
<label for="field_7_2" class="form_choice_text">Neutral</label>
<br>
<div class="radio" id="uniform-field_7_3"><span>
<input type="radio" class="form_radio" value="Unsatisfied" id="field_7_3" name="field_7" style="opacity: 0;">
</span></div>
<label for="field_7_3" class="form_choice_text">Unsatisfied</label>
<br>
<div class="radio" id="uniform-field_7_4"><span class="checked">
<input type="radio" class="form_radio" value="Very Unsatisfied" id="field_7_4" name="field_7" style="opacity: 0;">
</span></div>
<label for="field_7_4" class="form_choice_text">Very Unsatisfied</label>
<br>
<input type="hidden" value="5" name="field_7_length">
<div class="instruction" id="field_7_tip"></div>
</div>
</li>

我想隐藏文字“满意,中立,不满意”,只留下“非常满意和非常不满意”。你能告诉我如何使用Jquery隐藏这个文本吗?或CSS,如果它适用于 IE8

2 个答案:

答案 0 :(得分:3)

仅限CSS

使用adjacent sibling selectors

#uniform-field_7_1 + label,
#uniform-field_7_2 + label,
#uniform-field_7_3 + label{display:none} 

attribute-selectors

label[for="field_7_1"],
label[for="field_7_2"],
label[for="field_7_3"]{display:none}

答案 1 :(得分:1)

如果ids永远不会改变,你可以用CSS隐藏

#uniform-field_7_1, #uniform-field_7_2,
#uniform-field_7_3 { display: none !important; }

和标签使用jquery

$('label[for*="field_7_1"], label[for*="field_7_2"], label[for*="field_7_3"]').hide();