隐藏基于类名的DIV包含

时间:2017-08-25 13:13:42

标签: html css

所以我有一些代码可以枚举一些资源并且效果很好。我遇到的困难是隐藏一些包含某个单词或文本的资源。有没有一种简单的方法可以实现这一目标。使用以下代码。

这是枚举我所有资源的代码。

url = $configXml.find('resourcesProxy').attr('listURL    ajaxWrapper({ url: url, success: listResourcesSuccess });
    } else {
        showMessage('Login failed - try again');
    }
}

function loginError() { console.log('Loginled'); }

function logoffSuccess() {
    showMessage('You have logged off successfully');
    showLogonForm();
}

function showLogonForm() {
    $('#resources-container').empty();
    $('form').show();
    $('#username').select().focus();
}

function listResourcesSuccess(data) {
    var markup = '';

    resourcesData = data.resources;


    for (var i = 0; i < resourcesData.length; i++) {
        markup += generateResourceMarkup(resourcesData[i], i);
    }


    $('#resources-container').append($(markup))
                             .off('click')
                             .on('click', '.resource', null, prepareLaunch);

这是同一个html文件中的embed style.css。

    .resource {
    width: 75px;
    height: 75px;
    -ms-border-radius: 8px;
    border-radius: 8px;
    display: inline-block;
    padding: 5px;
    overflow: hidden;
    border: 1px solid blue;
    margin: 10px;
    position: relative;
    vertical-align: top;
}

.resource img {
        height: 42px;
        width: 42px;
        position: absolute;
        top: 6px;
        left: 21px;
    }

    .resource p {
        margin: 47px 0 0;
        text-align: center;
    }

    .resource:hover {
        background: lightgoldenrodyellow;
        cursor: pointer;
    }

以下是结果和资源名称,是我想要过滤的内容。 Result

1 个答案:

答案 0 :(得分:1)

感谢帮助人员,我实际上能够弄明白。我将下面的代码放在枚举代码的末尾,然后就可以了!

$("div p:contains('C607'), div p:contains('T607'), div p:contains('B607'), div p:contains('M607')").parent('div').hide();
相关问题