How can I implement this?
Thank you!
RightJS uses browser native css selectors, and although you might
find :contains in specs, modern browsers don't support this feature,
so doesn't RightJS.
jQuery emulates this pseudo-selector along with some others.
With RightJS you can have about the same result using Array#filter
method, kinda like that
$$('my rule').filter(function(td) { return
td.innerHTML.includes(my_string); });
It is certainly a bit longer, but generally does exactly the same
thing.
There are also plans for implementing a plugin with additional CSS
features, but it won't happen soon.
--
Cheers,
Nik
window.$$filter=function(selector, regexp, negative){
negative = negative || false;
return $$(selector).filter(function(element){
if(/input/i.test(element.tagName)){
if(negative==true) return
regexp.test(element.value)==false;
else return regexp.test(element.value)==true;
}else{
if(negative==true) return
regexp.test(element.innerHTML)==false;
else return regexp.test(element.innerHTML)==true;
}
});
}
document.onReady(function(){
//This will hide all the TR's that don't have TD's containing
'lorem ipsum'
$$filter('td', /lorem ipsum/,
true).each('parent','tr').each('hide');
});
if(negative==true) return
regexp.test(element.value)==false;
else return regexp.test(element.value)==true;