Yes, you are doing something wrong. Attribute selector selects elements with a specific attribute. . innerText is a property , not an attribute - as you know, using prop to set it.
You have two options. One of them is to use the selector :contains :
"ul.lower-menu li a:contains(" + PanelSettings[tab_name_key] + ")"
This, however, will choose foobar if you ask foo . The best option is to do the filtering yourself using filter :
var selector = "ul.lower-menu li a"; var els = $(selector).filter(function() { return $.text([this]) === PanelSettings[tab_name_key]; });
Here, only those elements are selected whose textual content matches the specified parameter.
NB also, as Diodeus says, you should use text() , not prop('innerText') .
source share