Tip of the day: Blank href in html A link

When you are using <a> link and want to bind it with onclick event in stead of href location, it can be set to # as following

<a href="#" onclick="javascript:callMethod();">Link</a>

As you know setting href to “#some_id” is an approach used to link content inside the page so if you are using above approach, it will make the page¬†jump to top which is not an elegant solution.

There is an alternate way which is much better as it does not make page jump.

<a href="javascript:void(0)" onclick="javascrit:callMethod();">Link</a>

Simple and elegant..


Leave A Comment

Your email address will not be published.