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

I'm trying to get to the default home link(href) on my sharepoint site using jquery but i keep getting href is undefined. I would like to change it to another URL I have tried

alert($(".static selected menu-item")[0].href).text();

<div class="s4-lp s4-toplinks">
        <div class="s4-tn" id="zz17_TopNavigationMenuV4">
            <div class="menu horizontal menu-horizontal">
                <ul class="root static">
                    <li class="static selected">
                    <a accesskey="1" href="/sites/Home" class="static selected menu-item" style="height: 11px; margin-top: 0px;">
                    <span class="additional-background">
                    <span class="menu-item-text">Home</span>
                    <span class="ms-hidden">Currently selected</span></span></a>

Any ideas what i'm doing wrong Thanks

share|improve this question
Why use the jQuery hammer here? Yes you can, but should you? Why not change your navigation settings so that the Home link is now point where you want it? – GavinB Nov 22 '11 at 22:39
This type of customisation is prone to fall over with the next release of SharePoint when they want to upgrade. Using a more supported mechanism will help make these kind of transitions easier and make it easier to support. – Russell Dec 23 '11 at 2:58

You are trying to select an element with multiple classes. Try this instead:


share|improve this answer


share|improve this answer

Try this instead alert($('static selected menu-item')['prevObject'][0].URL);

EDIT: If this works, you could also use $('static selected menu-item').end()[0].URL removing the 'prevObject' to make it future-proof.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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