How to make link in top navigation not clickable
-
10-12-2019 - |
Question
In my top navigation there are several links which are basically subsites. Under subsites are further sites or pages. I am using SharePoint 2013 default top navigation in my custom master page. I got its code from "Design Manager".
There is a particular top level subsite which I want to make unclickable. For e.g. currently this is the top navigation.
Home
Subsite1
Subsite2
Subsite3
Subsite4
Subsite5
I want to make Subsite1 unclickable so is there a way to put a # in its URL so when user clicks it, nothing happen.
Solution
You could achieve that using jQuery. Get the first link of the dropdown menu and set the href of that link.
$(function() {
$("#DeltaTopNavigation > div > ul > li > ul > li > ul > li > a:first").attr("href", "#");
});
If you want the link to be completely unclickable, then you could also remove its attribute.
$(function() {
$("#DeltaTopNavigation > div > ul > li > ul > li > ul > li > a:first").removeAttr("href");
});