Home » Php » a href javascript link adds unwanted hash value in address bar

a href javascript link adds unwanted hash value in address bar

Posted by: admin October 26, 2017 Leave a comment

Questions:

I have a javascript link

<a href="javascript:hideSideBar();" style="color: #fcfcfc;" data-toggle="tooltip" data-original-title="Hide Comments" data-placement="right"> <span class="glyphicon glyphicon-remove"></span> </a>  

that calls this function

function hideSideBar(ID) {
    var selector = ".sidebar";
    if (ID !== undefined) {
        selector = "#" + ID + selector;
    }
    $(selector).hide("slide",{ direction: "right" });
    $(".sidebar-btn").show("slide",{ direction: "right" });
}  

that for some reason adds '#javascript:hideSideBar();' to the address bar.

this is the only place where it does that and I can’t figure out why it does that or how to get rid of it?

Answers:

I was able to achieve what I needed with this

<a href="javascript:hideSideBar();" class="btn btn-default" role="button"> <span class="glyphicon glyphicon-remove"></span> </a>

Leave a Reply

Your email address will not be published. Required fields are marked *