What is the reason for using javascript:{} in the code below. Is it similar to href="javascript:" or href="javascript:void(0)"?
<a href="javascript:{}">This is an example</a>
What is the reason for using javascript:{} in the code below. Is it similar to href="javascript:" or href="javascript:void(0)"?
<a href="javascript:{}">This is an example</a>
 
    
     
    
    Let hyperlink look like a link but didn't link anything.
<a href="javascript:{}">This is an example</a>if you remove href attribute, that a tag will be normal text.
 
    
    It makes a button act like a link, but lets you execute custom JS code instead of linking to a webpage.
For example:
<a href="javascript:{ document.write('hi u just pressed me');}"> Press me pls </a>acts like
<div onclick="doOnClick()"> Press me pls </a>
<script>
    function doOnClick(){ document.write('hi u just pressed me'); }
</script>but the browser treats the former like a link.
