JQUERY图像滑块

时间:2012-05-01 20:14:59

标签: jquery css html5

嘿我想要点击每个图像时用一个简单的下拉列表做一个简单的jquery图像滑块,如果有人可以帮助我它将是一个救星,因为我不是很好,仍然学习HTML和jquery 。到目前为止,我的代码就是这个

<html>
    <head>
        <meta content='text/html; charset=UTF-8' http-equiv='Content-Type'/>
        <link rel="stylesheet" type="text/css" href="eventspage.css" />
        <title>Events page</title>
        <style>
            img {
                float:left;
            }
            .container {
                width:60%;
                margin
            }
            #slider {
                width:400px;
                background-color:green;
                height:200px;
            }
            div {
                position:absolute;
            }
            .window {
                width:400px;
                height:400px;
                overflow:hidden;
                background-color: aqua;
            }
        </style>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.js"></script>
    </head>
    <body>
        <div class="container">
            <button id="left">left</button> <button id="right">right</button>

            <div class="window">
                <div id="slider" class="block">
                    <img width="200px" src="person1.jpg">
                    <img width="200px" src="person2.jpg">
                </div>
            </div>
        </div>      

        <script>
            $("#right").click(function(){
                $(".block").animate({"left": "+=100px"}, "slow");
            });

            $("#left").click(function(){
                $(".block").animate({"left": "-=100px"}, "slow");
            });
        </script>
    </body>
</html>

2 个答案:

答案 0 :(得分:-1)

jQuery Cycle是事实上的jQuery图像滑块插件,基本上可以完成所有操作。

我不完全确定下拉列表的含义,但在Cycle之上可能很容易实现。

答案 1 :(得分:-1)

对于问题的下拉部分:

您可以通过在图像

上添加jquery事件处理程序来完成此操作
$("#slider img").click(function() {
  //CODE TO OPEN THE DROPDOWN
});