I have an object (in this case a rating object from js-kit) that I want to make invisible if the rating value is \'unrated\'. I\'m having trouble with getting the right jQue
A slight variant on @tgmdbm's excellent answer. The only difference being that it only selects nodes that have a single child text node exactly matching the hasText()
argument. Whereas .innerText
returns the concatenation of all descendant text nodes.
if( ! $.expr[':']['hasText'] ) {
$.expr[':']['hasText'] = function( node, index, props ) {
var retVal = false;
// Verify single text child node with matching text
if( node.nodeType == 1 && node.childNodes.length == 1 ) {
var childNode = node.childNodes[0];
retVal = childNode.nodeType == 3 && childNode.nodeValue === props[3];
}
return retVal;
};
}