1182 posts
  • Has been part of the Envato Community for over 5 years
  • Has referred 1+ members
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
campolar says

Hi. I’m working on a template and i wanted to add some jquery. Unfortunately its not working how i wanted it to O_o

What do i want?

I basically need the anchor links within a div with an id of x, so move (slide) up 5px.

My code

My HTML is just what is should be.

My css has the anchor tags within that div are positioned relative.

My current jquery code for that is as follows (yes its within the document load function):

$(’#x a’).hover(function() {
$(this).stop().animate({bottom : ‘5px’}, 100);
}, function() {
$(this).stop().animate({top : ‘0’}, 200);
});

The Problem

When i hover over it, it moves up 5px just fine. When i move away from it, it goes back down just fine. But then if i hover over it again, it doesn’t work! :S

PLEASE help!!!

741 posts
  • Had an item featured on Envato Market
  • Won a Most Wanted contest
  • Has been part of the Envato Community for over 5 years
  • Has sold $40,000+ on Envato Market
+4 more
Orbital_Themes says
Try using “top” or “bottom” in both functions, like this:
$(’#x a’).hover(function() {
$(this).stop().animate({bottom : ‘5px’}, 100);
}, function() {
$(this).stop().animate({bottom : ‘0’}, 200);
});

Also make sure, that the anchor element has the CSS property “bottom” applied to it.

Demo would be useful!

470 posts
  • Sells items exclusively on Envato Market
  • Has been part of the Envato Community for over 5 years
  • Has sold $250,000+ on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+6 more
SaurabhSharma says

Yep. use bottom for both cases.

1182 posts
  • Has been part of the Envato Community for over 5 years
  • Has referred 1+ members
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
campolar says
Try using “top” or “bottom” in both functions, like this:
$(’#x a’).hover(function() {
$(this).stop().animate({bottom : ‘5px’}, 100);
}, function() {
$(this).stop().animate({bottom : ‘0’}, 200);
});

Also make sure, that the anchor element has the CSS property “bottom” applied to it.

Demo would be useful!

Didn’t i do that? Oh wait, how the hell did i add top in the second function? Damn, must have been the designers’ Satan

Thanks! I can’t figure out how i missed that! Yes, it worked :)

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by