仅检查jQuery中一个表行的条件

在发生这种情况后,我编写了以下代码来删除一些类:

 if ($('span.dashboard__icon.dashboard__icon--small.fa.fa-circle').hasClass('text-info')) {
        $('tr.form-table__row--extra').removeClass('hidden');
    } else {
        $('i.dashboard__icon.fa.fa-circle.text-info').remove();
    }

but I have a problem. I need this if else to be applied for one one particular table row. Because if one table row doesnt fulfill these criteria the other one does and it affects that as well. Therefore, I tried doing something like this (for each row to check this):

$('.form-table__row').each(function() {
    if ($('span.dashboard__icon.dashboard__icon--small.fa.fa-circle').hasClass('text-info')) {
        $('tr.form-table__row--extra').removeClass('hidden');
    } else {
        $('i.dashboard__icon.fa.fa-circle.text-info').remove();
    }
})

但是它仍然不起作用,因为它不检查并仅应用于一个表行。对此我的任何帮助将不胜感激。

评论