.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
- $("a")
-
- .mousedown(function() {
- $(this).css("marginTop","1px");
- })
-
- .mouseup(function() {
- $(this).css("marginTop","0px");
- });
-
^ This makes all the A tags shift, regardless of which is clicked
- $("a")
-
- .mousedown(function() {
- $(this).css("color","red");
- })
-
- .mouseup(function() {
- $(this).css("color","black");
- });
-
-
^ This makes just the clicked link turn red and then it returns to black on mouseup.