Deepak Kumar
Deepak Kumar

Reputation: 221

How to add link in left part of suitebar in Sharepoint 2013

I have to add a link in left part of suitebar of my site in Shareoint 2013.

I have tried using JS. My code is :-

<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.12.4.min.js"></script>
<script>
var customLi = "<li class='ms-core-suiteLink'><a class='ms-core-suiteLink-a' target='_blank' href='https://rootsite/SitePages/Home.aspx'>Home</a></li>";
if(jQuery("div#suiteLinksBox").children("ul").length > 0){
        jQuery("div#suiteLinksBox").children("ul").append(customLi);
       }
else {
        jQuery("div#suiteLinksBox").html('<ul class="ms-core-suiteLinkList">' + customLi + '</ul>' )
}
</script>

I am not getting the desired result. Can someone suggest some other way or help me with the solution.

Upvotes: 0

Views: 116

Answers (1)

Lee
Lee

Reputation: 5493

Try this.

<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.12.4.min.js"></script>
    <script type="text/javascript">
        $(function () {
            var customLi = "<li class='ms-core-suiteLink'><a class='ms-core-suiteLink-a' target='_blank' href='https://rootsite/SitePages/Home.aspx'>Home</a></li>";
            if ($("div#suiteLinksBox").children("ul").length > 0) {
                $("div#suiteLinksBox").children("ul").append(customLi);
            }
            else {
                $("div#suiteLinksBox").html('<ul class="ms-core-suiteLinkList">' + customLi + '</ul>')
            }
        })

    </script>

enter image description here

Upvotes: 1

Related Questions