0

我正在尝试向右滑动但不工作,当我尝试写“右”或“左”而不是“切换”时。它不工作。请帮助我我的代码如下。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('ul').hide();

});
function next(){

$('ul').animate({width: 'toggle'}, 1000);
}
</script>
<style>
ul{height:30px; overflow: hidden; }
ul li{ display: inline-block; padding: 10px; }
</style>
</head>

<body><p onclick="next()">next</p>

<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
</ul>

</body>
</html>
4

2 回答 2

0

在这里工作演示:演示

JS代码:

$(document).ready(function(){
    $("ul").hide();
    $("p").click(function(){        
           $("ul").show("slide",{direction: 'right'})
    });

});
于 2013-07-26T05:07:58.400 回答
0

您可以尝试在以下位置提供的滑动解决方案:jQuery .slideRight effect

$(document).ready(function() {
    $('#slider').click(function() {
        $(this).animate(
            {
                'margin-left':'1000px'
                // to move it towards the right and, probably, off-screen.
            },1000,
            function() {
                $(this).slideUp('fast');
                // once it's finished moving to the right, just 
                // removes the the element from the display, you could use
                // `remove()` instead, or whatever.
            }
        );
    });
});
于 2013-07-26T06:20:32.407 回答