Question: I need to use jQuery's `addClass` to change the selected anchor tag's style. It is working fine. But after changing the style I want to navigate to a link specified in the `href`. This is not working since I am using `return false;` or `e.preventDefault()`.

Please help me.

The code which I am using is:

```
$("li").click(function (e) {
    e.preventDefault();
    $("li").removeClass("active");
    $(this).addClass("active");
});

<div id="navigation" class="right">
    <ul>
        <li id="nav1"><a href="../WebForm1.aspx"><span>Home</span></a></li>
        <li id="nav2"><a href="../AboutUs.aspx"><span>About Us</span></a></li>
    </ul>
</div>

```

Here the style is applied after clicking the Home link but I want it to navigate to `webform1.aspx` after this.

Answer: 
you need to check if your `li` tag contains active class, if it has then go to the specified link.

```
$("li").click(function (e) {
  if($(this).hasClass('active')){
      return true;
  }else{
    e.preventDefault();
    $("li").removeClass("active");
    $(this).addClass("active");
  }
});

```

[DEMO](http://jsfiddle.net/y7FTH/)
DEMO: <http://jsfiddle.net/hBubq/1/>

**EDIT** You might need to use an absolute URL in each of your `<a href=""` objects

```
$("li").click(function (e) {
    e.preventDefault();
    $("li").removeClass("active");
    $(this).addClass("active");
    window.location.href =  $(this).find('a').attr('href');
});

```

​ 

```
<div id="navigation" class="right">
   <ul>
      <li id="nav1"><a href="../WebForm1.aspx"><span>Home</span></a></li>
      <li id="nav2"><a href="../AboutUs.aspx"><span>About Us</span></a></li>
   </ul>
</div>

```