我有html:
<div class="items-list-container">
<div class="fieldset-item">Something</div>
<div class="fieldset-item">Something 2</div>
<div class="fieldset-item">Something 3</div>
<div class="fieldset-item">Something 4</div>
<div class="fieldset-item">Something 5</div>
</div>
我需要用 jQuery 找出变量t
是否与文本相同,fieldset-item
如果它是 - 将fieldet-item
class css 设置为:display: block
。例如,如果
t = "Something 2"
html 应如下所示:
<div style="display: block;" class="items-list-container">
<div class="fieldset-item">Something</div>
<div style="display: block;" class="fieldset-item">Something 2</div>
<div class="fieldset-item">Something 3</div>
<div class="fieldset-item">Something 4</div>
</div>
我可以在 div 中找到所有文本:
var text = $(".items-list-container").text();
我应该如何将 css 添加到特定匹配的 div 中?