How can i get the value Communications?
<li class="current">
<a href ="" class="sf-with-ul">
Communications<span class="sf-sub-indicator"></span>
</a>
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.
Sign up to join this communityHow can i get the value Communications?
<li class="current">
<a href ="" class="sf-with-ul">
Communications<span class="sf-sub-indicator"></span>
</a>
Previous answers are correct, but I'll add to it a tad.
If you want a solution that works consistently and you only want that one item (as opposed to a parent object containing all of the matches), you really need to tie it to an ID.
For an example, if this was a nav menu it probably has an id attribute (somewhere above it). It doesn't matter if that id is called on the ul tag, or on some higher object like a div or table. You can then grab instances of sf-sub-indicator within that ID to ensure it's processed consistently. Using a blanket selector like you are means if someone adds a anchor tag with that class it'll get returned back since there's no scope on it.
The better approach is to use something like $("#divid li.sf-sub-indicator").text();
From your excerpt, there is no way to guarantee that an expression will return the value "Communications". It depends on the rest of your page.
Based only on your 4 lines, you can do this:
$("a .sf-with-ul").text()