A: 

Alerting works for me. However why would you add a class if you are redirecting to a new page?

Dmitri Farkov
After redirection the class won't matter. If you dont wan't to follow the link try: return false;
Dmitri Farkov
+2  A: 
$("#better a").bind('click', function() { $(this).addClass('active'); });
Ravish
Doesn't make sense to me. If the above didn't work. Only changes are now ANCHORS selected are **not** direct descendants but any descendants. **.click** is just shorthand for **bind('click', func)** if you look through jQuery source code.
Dmitri Farkov
This could cause unforeseen problems by attaching the click event to unwanted anchor tags. Without knowing the rest of your markup, make sure there aren't other anchor tags inside "better" that don't need the click event attached
T B
This worked -- my original code didn't. Not sure why or what the difference is.
Alex
@T B: I only have anchor tags inside the target div that I do want affected. Thank you for pointing out the danger though.
Alex
@Alex: I think the difference is the parent-child selector ">"... it's just something I've noticed because I can't get it to work for me properly, so I always just resort to ".find()" or just using a space.
fudgey
@fudgey: That's true. I can do the .click (instead of bind) as well. The difference was indeed the parent child selector.
Alex
A: 

Two guesses:

  1. Do you maybe have another element on your page with id="better"? ID is supposed to be globally unique, so the selector will only return one of them.

  2. Try making your click function return false, to keep the user from following the link. (Seems strange to add a class when the user is leaving the page, unless maybe the link opens in a new window.)

Kip
A: 

Try running the code at the bottom of the page right before the closing body tag or in a $(document).ready() function.

Using Firebug, you can use console.log() to write out to the javascript console to make sure the selector is actually returning elements. example: console.log($("#better > a").length)

T B
+1  A: 

If I understand what you're asking.. you want to end up with this?

<div id="better">
    <a href="1.aspx" class="active">One</a>
    <a href="2.aspx" class="active">Two</a>
    <a href="3.aspx" class="active">Three</a>
</div>

If any link in that div was clicked, right? (you did say ALL anchor tags)... then use this:

$("#better").click(function() {
 $(this).find('a').addClass('active');
 return false;
});
fudgey