2009-07-31 5 views

Antwort

1
$(function(){ 
    /* Set initial height to variable */ 
    var defaultTop = $("button.special").click(function(){ 
    /* On click, get current height */ 
    topVal = $(this).css("top").split("px")[0]; 
    /* If current height is different */ 
    if (topVal != defaultTop) { 
     /* Reset height to original */ 
     $(this).css("top", (defaultTop+"px")); 
    } else { 
     /* Else, increase by a fourth of the value */ 
     $(this).css("top", ((Number(defaultTop) + Number((defaultTop/4)))+"px")); 
    } 
    }).css("top").split("px")[0]; 
}); 

button.special { position:relative; top:100px; } 

<button class="special">Click Me!</button> 
Verwandte Themen