简体   繁体   中英

jQuery Animate Slide Left

I am trying to slide an image left using jquery animate with the easing plugin and it doesn't seem to want to work.

I have an image with the id=1 and the following javascript

$(document).ready(function() {
    $('#center-photo img:first').show();
$('#next').click(function() {
    var active = $('#center-photo img:first');
    //Slider Animation
    $('#1')
    .animate(
    { left: 200 }, {
     duration: 'slow',
     easing: 'easeOutBounce'
    })
   .animate(
    { left: 0 }, {
     duration: 'slow',
     easing: 'easeOutBounce'
    });

});
});

next is the link I click to do the animation.

First

What are valid values for the id attribute in HTML?
ID's CANNOT START WITH A DIGIT
It will screw up validation as well as mess with the way browsers parse your html

Second What is the position of your image with the id of 1.

A common problem with element positioning is normally when it is defaulted to static try changing the position to relative or absolute.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM