Question: In our page we have a slew of anchor tags to which we dynamically attach click handlers. In such a case what is the best way to keep an anchor tag in the mark up?

Currently we have

```
<a href="javascript:void(0);" >....</a>

```

We need void value for href as some of them may not get attached with click handlers.

Answer: 
Returning false from a jQuery event handler will prevent the default behavior (and bubbling) *for you*. There's no need to mess with the `href` attribute (though that won't hurt). 

```
$(document).on("click", "a.yourSelector", function(){
    //your code

    return false;
});

```

Or of course jQuery pre 1.7

```
$(document).delegate("a.yourSelector", "click", function(){
    //your code

    return false;
});

```

For more information on cancelling dom events, see [this question (and answer)](https://stackoverflow.com/questions/1357118/javascript-event-preventdefault-vs-return-false) and [this link](http://blog.niftysnippets.org/2011/11/story-on-return-false.html)
The simpler code would be like this:

```
<a href='#' class='do-stuff'>Link</a>

```

The "#" sign keeps the html code clean, and readable

```
jQuery(document).ready(function() {

  jQuery(".do-stuff").click(function() {
    alert("clicked"); 
    return false; // disables default link action
  });

});

```