.mousedown / .mouseup issue

.mousedown / .mouseup issue

Hey all,

I'm trying to simulate a button click on all links by adding a 1px margin to all links when there's a mousedown and taking it away when there's a mouseup.

The issue is that when I click on one link, all the links on the page are shifting rather than the one that I click on. 

If I use the same exact code but add "color", "red" instead of "marginTop", "1px", it works perfectly fine.

Am I doing something wrong? Is this a total id10t issue on my part?

--nks

  1. $("a")
  2. .mousedown(function() {
  3. $(this).css("marginTop","1px");
  4. })
  5. .mouseup(function() {
  6. $(this).css("marginTop","0px");
  7. });
^ This makes all the A tags shift, regardless of which is clicked

  1. $("a")
  2. .mousedown(function() {
  3. $(this).css("color","red");
  4. })
  5. .mouseup(function() {
  6. $(this).css("color","black");
  7. });
^ This makes just the clicked link turn red and then it returns to black on mouseup.