2013-05-20 26 views
-3

我的第一篇文章在這裏! 任何人都可以請告訴我如何創建一個類似於Slideshare的搜索框效果,點擊搜索框以一定的速度改變長度,並以一定的速度恢復其原始大小,即不是一次,這是發生什麼我小的代碼:幻燈片般的搜索框?

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"; 
}` 
+0

搜索'jQuery的animations'。 http://api.jquery.com/animate/你也不需要改變提交按鈕的位置。適當的 「浮動」會自動移動。 http://www.w3schools.com/cssref/pr_class_float.asp – enenen

回答

0

最簡單的方法將使用jQuery動畫:

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