根据类和标题隐藏SPAN标记上的文本

时间:2013-08-20 14:52:59

标签: jquery css html

我想隐藏<span>标记内的内容,但使用特定文字:

<span class="ms-RadioText" title="Created / Criar"><input id="ctl00_m_g_178a35bf_4d92_4887_8b39_b6e6e11d4a09_ff21_ctl00_ctl00" type="radio" name="ctl00$m$g_178a35bf_4d92_4887_8b39_b6e6e11d4a09$ff21$ctl00$RadioButtons" value="ctl00" checked="checked" /><label for="ctl00_m_g_178a35bf_4d92_4887_8b39_b6e6e11d4a09_ff21_ctl00_ctl00">Created / Criar</label></span>
<span class="ms-RadioText" title="Change / Alterar"><input id="ctl00_m_g_178a35bf_4d92_4887_8b39_b6e6e11d4a09_ff21_ctl00_ctl01" type="radio" name="ctl00$m$g_178a35bf_4d92_4887_8b39_b6e6e11d4a09$ff21$ctl00$RadioButtons" value="ctl01" /><label for="ctl00_m_g_178a35bf_4d92_4887_8b39_b6e6e11d4a09_ff21_ctl00_ctl01">Change / Alterar</label></span>

我必须隐藏“ms-RadioText”类的内容和标题标签“Created / Criar”

4 个答案:

答案 0 :(得分:2)

所以只需定位该元素:

$('span.ms-RadioText[title="Created / Criar"]').hide();

注意:属性选择器也适用于CSS3。

答案 1 :(得分:0)

 //This removes it from the page
 $('span.ms-RadioText[title="Created / Criar"]').hide();  

 //same as above
 $('span.ms-RadioText[title="Created / Criar"]').css('display', 'none'); 

 //This makes it invisible, but it still exists in document flow
 $('span.ms-RadioText[title="Created / Criar"]').css('visibility', 'none'); 

答案 2 :(得分:0)

以下jQuery选择器适合您:

$('span.ms-RadioText[title="Created / Criar"]')

通过将它与jQuery的hide()函数组合如下,你应该得到你期望的结果:

$('span.ms-RadioText[title="Created / Criar"]').hide();

这是jsFiddle Demo

答案 3 :(得分:0)

您可以使用选择标题:

.ms-RadioText[title='Created / Criar']
{
  display: none;
}

工作演示here