過去数日間、javascript スライダーに取り組んできましたが、この瞬間まで、ページへのスライドの div を閉じるボタンでページからスライドさせる方法に行き詰まっています...私が持っているいくつかのコードを見つけました機能させようとしましたが、そうするのに非常に無頓着でした..これは、divを画面からスライドさせるために使用しようとしていたコードの2つの部分の横にコメントを付けた完全なコードです..
<script type="text/javascript">
$(function(){
$(".recordrow").click(function() {
var divid = "details-" + $(this).attr('id').split("-")[1]; //Create the id of the div
$("#"+divid).show().animate({ "left": '50.1%'}); //Bring the div from right to left with 200px padding from the screen
});
});
function closeRecord() { // this function
$('#details').animate({right:-1000}, 500);
}
</script>
<div class="recordrow" id="row-1">
<p>Matthew Gia </p>
</div>
<div class="details" id="details-1">
... More details of the records
<a href="#" id="bt-close" onclick="closeRecord(); return false;">Close</a> //this button
</div>
<div class="details" id="details-2">
... More details of the records
</div>
このjsフィドルもあります