SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can i get the value Communications?

<li class="current">
    <a href ="" class="sf-with-ul">
        Communications<span class="sf-sub-indicator"></span>
share|improve this question

closed as off topic by Alex Angas Sep 14 '10 at 1:33

Questions on SharePoint Stack Exchange are expected to relate to SharePoint within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

This question is not related to SharePoint specifically and would be better asked on a JQuery forum. – Charles Lee Sep 13 '10 at 8:25
@Patrick: You have been repeatedly warned about asking off topic questions. If there's something you're not clear about regarding this please e-mail Your account has been suspended for 48 hours. – Alex Angas Sep 14 '10 at 1:38
up vote 0 down vote accepted

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();

share|improve this answer
Thanks for the solution and i get what you mean. i'm using a UL and it has no id.But will work something out – Patrick Sep 14 '10 at 4:43


share|improve this answer

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()

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.