2011-11-10 17 views

答えて

3

Here's a working example。あなたがバットからすぐに考えているほど単純ではありません。

+0

ブライアンのおかげで助けをちょっと、私はであなたの例をしようと試みjsfiddle&それを働かせることができる(私はprobabだ何かが欠落している)。コンソールに表示されていると、output'Uncaught TypeError:Object [オブジェクトオブジェクト]にメソッド 'on'(無名関数)がありません '。 – Cam

+0

、jQuery(document).ready内に配置する必要がありました。魅力的です!再度、感謝します – Cam

0

あなたは(.animateを行う必要があります)動的なdiv要素の幅にし、あなたのカウンターをスライドされているどんな長さの負にwidthプロパティを設定します

.animate({width: -50}) 

にdivが右あなたのスライダーの呼び出しの前または後にこの呼び出しを行います。

もう一つの提案は、ボタンとカウンタ要素をラッパー要素に入れ(これはHTMLの再構成が必要です)、そのラッパー要素をスライドさせるだけです。

0

簡単な解決策は、アニメーションをラッパーdivに適用することです。だからあなたのslideRightShowに、あなたが持つことができます。

$('#caption').show(); 
$('#caption-wrap').show('slide', {direction: 'right'}, 1000); 
0

これは、別の解決策のようになります。

HTML:

<div class="test" id="hithere">Hi there, <a href="#" id="hide">Hide me</a></div> 
<a href="#" id="show">Show me</a> 

CSS:

.test { 
    border: 1px solid black; 
    background-color: yellow; 
    padding: 10px; 
    position: absolute; 
    visibility: hidden; 
} 

JS

var variableWidth; 

$(window).load(function() { 

// gets complete element width (including margins), moves it out of the screen and sets visibility to its default 
    variableWidth = $('#hithere').outerWidth(true); 
    $('#hithere').css("left", variableWidth * -1); 
    $('#hithere').css("visibility", "visible"); 
}); 

$("#show").click(function() { 
    $('#hithere').animate({left: 0}, 400); 
    }); 

$("#hide").click(function() { 
     $('#hithere').animate({left: variableWidth * -1}, 400); 
     }); 
関連する問題