Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

How can i get the value Communications?

<li class="current">
    <a href ="" class="sf-with-ul">
        Communications<span class="sf-sub-indicator"></span>
    </a>

Thanks in advance

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 team@sharepointoverflow.com. Your account has been suspended for 48 hours. –  Alex Angas Sep 14 '10 at 1:38

3 Answers 3

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
$(".sf-sub-indicator");

see http://api.jquery.com/class-selector/

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.