0
如果我用下面的语句兄弟...添加类一旦兄弟发现
if ($('divA').siblings().text() == "1") {
the code here needs to add a class to that specific sibling where text = 1
}
我怎么会选择兄弟div来添加类?
如果我用下面的语句兄弟...添加类一旦兄弟发现
if ($('divA').siblings().text() == "1") {
the code here needs to add a class to that specific sibling where text = 1
}
我怎么会选择兄弟div来添加类?
$('divA').siblings().filter(function(index) {
return $(this).text() == "1";
}).addClass('yourClass');
可以使用.filter()功能的.siblings()
收集减少那些只返回true你的病情,然后用.addClass()
你的类添加到过滤的兄弟姐妹。