2010-07-06 38 views

回答

1

我使用這個jQuery手風琴小部件。它有一個鼠標懸停效果,就像一個上heroku.com

http://jqueryui.com/demos/accordion/#mouseover

+0

他們甚至不使用用戶界面或插件 – mplungjan 2010-07-06 14:14:17

+0

加載整個庫的一個作用似乎是一個壞主意。 – 2010-07-06 14:22:52

+0

網頁上的另一個70K是什麼?我的手機供應商的主頁是 0.5MB,當我將其加載到我的手機上時... – mplungjan 2010-07-06 14:27:34

1

簡單的jQuery。 查看來源,看看如何

1

試試這個,如果你不需要加載整個jQuery庫。 A simple div slide down JS script

function doSlide(id){ 
    timeToSlide = 50; // in milliseconds 
    obj = document.getElementById(id); 
    if(obj.style.display == "none"){ // if it's allready hidden we slide it down 
     obj.style.visibility = "hidden"; 
     obj.style.display = "block"; 
     height = obj.offsetHeight; 
     obj.style.height="0px"; 
     obj.style.visibility = "visible"; 
     slideDown(obj,0,height,Math.ceil(height/timeToSlide)); 
    } else { 
     slideUp(obj,Math.ceil(obj.offsetHeight/timeToSlide),obj.offsetHeight); 
    } 
} 

function slideDown(obj,offset,full,px){ 
    if(offset < full){ 
     obj.style.height = offset+"px"; 
     offset=offset+px; 
     setTimeout((function(){slideDown(obj,offset,full,px);}),1); 
    } else { 
     obj.style.height = full+"px"; //If the data inside is updated on runtime you can use auto instead... 
    } 
} 

function slideUp(obj,px,full){ 
    if((obj.offsetHeight-px) > 0){ 
     obj.style.height = obj.offsetHeight-px+"px"; 
     setTimeout((function(){slideUp(obj,px,full);}),1); 
    } else { 
     obj.style.height=full+"px"; // we reset the height if we were to slide it back down 
     obj.style.display = 'none'; 
    } 
}