【发布时间】:2018-12-07 16:45:57
【问题描述】:
如何将类附加到包含特定文本的特定元素,如下所示:
var title = $('.pass-item .title').text();
if(title.includes('7 days within 1')){
// Here I want to select the element which has the title text '7 days within 1'
// And append a class to it
}
希望有人能帮帮我:)
【问题讨论】:
-
$('.pass-item .title').addClass("yourClassName") -
@Chiller
title将是一个字符串 -
@George,已修复,谢谢我错过了
-
标题只是
className吗?例如:.title,还是tagName?前任。<title></title>,还是一个属性?例如:<div title="string representing the value of title">
标签: javascript jquery