user1160232
user1160232

Reputation: 98

Javascript Animate won't work

I want to change the width or right position, but neither are working.

This is what I've included in my HTML file (I have Jquery linked):

<script type="text/javascript">
$(document).ready(function() {
    $("#slide").click(function(){
        $('#contact-wrap').animate({
            right: '0'
        }, 500);    
    }); 
}); 
</script>

I have an anchor's id set to "slide" and I want the div named "contact-wrap" to change from its negative right value to 0. I'm guessing that my JS code is wrong.

Upvotes: 0

Views: 1343

Answers (1)

Zen Pak
Zen Pak

Reputation: 578

I have tested your javascript and it looks alright and slides the div accordingly. My test html, css and jscript are:

css:

#contact-wrap 
{     
    height: 30px; 
    width:10px;
    border:solid 1px black; 
    display: block;
    position:absolute;right:-200px;
}


html:

<a id="slide">test</a>
<div id="contact-wrap"></div>


javascript:

$("#slide").click(function(){             
    $('#contact-wrap').animate(
        { right: '0' }, 
        500);             
}); 

Upvotes: 3

Related Questions