Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

jQuery Animate Problem :(

Featured Replies

I can't seem to get the jQuery animate function to work. Can anyone see where I've mucked up in my coding...

 

<!DOCTYPE HTML>

<html>

<head>
<title>jQuery Popout Menu</title>
<style>



</style>
<script type="text/javascript" src="http://jordan-adams.co.uk/res/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function() {

$('li span').hover(function() {

	$(this).animate({padding-left: 20px}, 500);

},
function() {

	$(this).animate({padding-left: 0px}, 500);

});

});
</script>
</head>

<body>
<ul>
<li><span>Foo Bar</span></li>
<li><span>Foo Bar</span></li>
<li><span>Foo Bar</span></li>
<li><span>Foo Bar</span></li>
<li><span>Foo Bar</span></li>
</ul>
</body>

</html>

this works

 

<html> 

<head> 
<title>jQuery Popout Menu</title> 

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> 
<script type="text/javascript"> 


$("a").hover(function(){ 
   $(this).animate({ 
       'padding-left': '+=10px' 
   }, "normal"); 
}, function(){ 
   $(this).animate({ 
       'padding-left': '-=10px' 
   }, "normal"); 
}); 
</script> 
</head> 

<body> 
<ul id="blah"> 
       <li><a href="#">Foo Bar</a></li> 
       <li><span>Foo Bar</span></li> 
       <li><span>Foo Bar</span></li> 
       <li><span>Foo Bar</span></li> 
       <li><span>Foo Bar</span></li> 
</ul> 


<script type="text/javascript"> 


$("a").hover(function(){ 
   $(this).animate({ 
       'padding-left': '+=10px' 
   }, "normal"); 
}, function(){ 
   $(this).animate({ 
       'padding-left': '-=10px' 
   }, "normal"); 
}); 
</script>
</body> 

  • Author

Thanks :) It was because I didn't have quotes around "padding-left." The jQuery documentation annoyingly doesn't show it like that.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.