当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - Slideshare-like search box?

问题描述:

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);
 });
分享给朋友:
您可能感兴趣的文章:
随机阅读: