0

Suppose that i have a 4-level deep sharepoint top navigation menu, and i want to replace the menu item links in second and third level with # (href='#')

How can i achieve this? With ajax? And how?

Thanks.

2
  • Is this a one-off change or are links at this level supposed to always be disabled?
    – Dave Wise
    Nov 12, 2012 at 21:30
  • second option ..
    – ozdogan
    Nov 12, 2012 at 22:14

2 Answers 2

1

This works on my test environment to change all all my dropdown links to '#'. I only had 2 levels though so you'll have to tweak accordingly. It should give you an idea though...

$(".s4-tn li.dynamic-children li.dynamic a").attr("href", "#");
1
  • actually, i was wondering why you need something like that in a project? i am curious about our requirements are the same
    – ozdogan
    Nov 14, 2012 at 17:38
0

By default, the global navigation (top nav) is controlled through the Navigation options in Site Settings. To accomplish this, try this:

  • go to the sites that are the parents of where the links should be #
  • click on Site Settings - Navigation
  • Hide the automatically created links for the child items that you want to be #
  • Create a new Heading with the same name as the the one that was hidden
  • Use the Move Up/Down functionality to move the actual child items that should appear under the heading

This this in place, everything that is defined as a Heading in the navigation will be visible but not clickable.

2
  • i was talking about doing this automatically not manual from UI.
    – ozdogan
    Nov 13, 2012 at 6:47
  • 1
    With this approach, the change is done once and then it would appear correctly regardless of the navigation provider used. Anything else would require using Javascript to identify the elements that you need to change and then changing them. Using the CSS selectors that jQuery supports would probably be a good way to find these items. Naturally, the selector itself would vary with the menu but it should be possible to do this in one or two lines of javascript with jQuery. Something like $('menu node > childnode a, menu node > childnode > childnode').attr('href','#');
    – Dave Wise
    Nov 13, 2012 at 16:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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