问题描述:

My first post here!

Can anyone please tell me how to create a searchbox effect like that of Slideshare where on click the searchbox changes length with a certain speed and get back to its original size with a certain speed,i.e,not at once,which is what happens with my small code:

function long()

{

document.getElementById("GS").style.width="300px";

document.getElementById("submit").style.left="1168px";

}

function back()

{

document.getElementById("GS").style.width="200px";

document.getElementById("submit").style.left="1068px";

}`

网友答案:

The easiest way would be using jquery animate:

http://api.jquery.com/animate/

$('#submit').click(function() {
 top.$('#submit').toggle(function() {
   $(this).animate({ 
     width: 1168
   }, 500);
   },
    function() {
   $(this).animate({ 
     width: 1068
   }, 500);
 });
相关阅读:
Top