up

jQuery link click href value

I've wrote these words on google. And I don't find the exact solution.

The problem:
What Should I write in the href? If I write # sign then browser go to the top of page. I wouldn't like to go to the top of page.

Here is the HTML:

<a href="#" id="example" >Click</a>

jQuery code:

<script>
$('#example').click(function() {
  alert('Hello');
  return false;
});
</script>

The
return false;
command is the key. When use this return value. The links lost their default behavior.

Add new comment