jQuery HTML Element How to - Prevent anchor tag from triggering status bar and make it not clickable








Question

We would like to know how to prevent anchor tag from triggering status bar and make it not clickable.

Answer


<!DOCTYPE html>
<html>
<head>
<script
  src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
</head><!--from   w  w w  .j a va2  s. c o  m-->
<body>
  <a href="www.google.ca">a link!!</a>
  <br>
  <script>
$(function () {
  $('a').each(function() {
    var $this = $(this),
        href = $this.href;
    $this.removeAttr('href').click(function() {
        window.location = href;
    });
  });
});
</script>
</body>
</html>

The code above is rendered as follows: