Is there a CSS selector for elements containing certain text?

后端 未结 18 2366
别跟我提以往
别跟我提以往 2020-11-21 04:26

I am looking for a CSS selector for the following table:

Peter    | male    | 34
Susanne  | female  | 12

Is there any selector to match all

18条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-21 05:13

    Doing small Filter Widgets like this:

        var searchField = document.querySelector('HOWEVER_YOU_MAY_FIND_IT')
        var faqEntries = document.querySelectorAll('WRAPPING_ELEMENT .entry')
    
        searchField.addEventListener('keyup', function (evt) {
            var testValue = evt.target.value.toLocaleLowerCase();
            var regExp = RegExp(testValue);
    
            faqEntries.forEach(function (entry) {
                var text = entry.textContent.toLocaleLowerCase();
    
                entry.classList.remove('show', 'hide');
    
                if (regExp.test(text)) {
                    entry.classList.add('show')
                } else {
                    entry.classList.add('hide')
                }
            })
        })
    

提交回复
热议问题