why we are using javascript:void(0) in Angular code

Issue

  <a href="javascript:void(0)" id="loginlink">login</a>

I’ve seen such anchor tag’s href property having javascript:void(0) value many times. I don’t know what exactly that means.I saw this when working with angular 5. Why is javascript:void(0) used as a value for href property?

Solution

javascript:void(0)

The snippet show above simply ignores the link “click.” This can be done in a similar fashion by the following:

<a href="#" onclick="return false;">link</a>

Answered By – Rob

Answer Checked By – Clifford M. (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.