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 jQuery selector to do this.
Even though the code below seems like it should work, it does not.
$(".js-rating-labelText:contains('unrated')").css("visibility", "hidden");
.js-rating-labelText
is a class that's set on the text.
Make sure your code is running after the js-kit function has populated the text, and not before it.
Perhaps the issues is with the
:contains('Unrated')
part of the function. As changing the text to any random value produces the same result:Here is some of the html coming from the javascript function:
The best way to explain the topic is by giving an example and a reference link:-
Example:- The following jQuery selector syntax selects the first or nth element from the set of already selected (matched) HTML elements.
Html:-
Jquery:-
Try this:
Based on the HTML you provided,I don't see where the 'unrated' text you're testing for is coming from.
However, if that is the entirety of the text in that div, just test for it directly.