单击BxSlider链接时如何更改图像?

时间:2016-09-03 05:21:03

标签: javascript jquery bxslider

我使用jQuery插件BxSlider。我想展示这部分,我的意思是一张图片,

<li id="miori"><img src="http://images.ciatr.jp/2015/12/09202601/05c36a2c5ba65065ac4f2a6f6c75b3e1_55.jpeg"></li>

当我点击这部分后。

<dd id="miori"><a href="">miori</a></dd>

我应该如何为该动作编写JavaScript代码? 你能给我一些建议吗?

<html>
<head>
    <title>bxslider</title>
    <link href="/jquery.bxslider/jquery.bxslider.css" rel="stylesheet" />
</head>
<body>

    <dl class="sample">
        <dt>menu</dt>
            <dd id="tao"><a href="">tao</a></dd>
            <dd id="miori"><a href="">miori</a></dd>
    </dl>  <!-- sample -->

    <ul class="bxslider">
        <li id="tao"><img src="http://koi-navi.net/wp-content/uploads/2015/10/5e9dd24e-e1444440113499.jpg"> </li>
        <li id="miori"><img src="http://images.ciatr.jp/2015/12/09202601/05c36a2c5ba65065ac4f2a6f6c75b3e1_55.jpeg"></li>
    </ul>  <!-- bxslider -->

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
    <script src="/jquery.bxslider/jquery.bxslider.min.js" type="text/javascript" ></script>}
    <script type="text/javascript">
        $(document).ready(function(){
            $('.bxslider').bxSlider();
            $('dd#miori').on('click', function(){
                alert("hello");  // what should I write here?
            });
        });
    </script>

</body>
</html>

1 个答案:

答案 0 :(得分:1)

参考:http://bxslider.com/examples/thumbnail-pager-1

试试这个:

<html>
    <head>
        <title>bxslider</title>
        <link href="/jquery.bxslider/jquery.bxslider.css" rel="stylesheet" />
    </head>
    <body>

        <!-- <dl class="sample">
             <dt>menu</dt>
                 <dd id="tao"><a href="">tao</a></dd>
                 <dd id="miori"><a href="">miori</a></dd>
         </dl>  <!-- sample -->
        <div id="bx-pager">
            <a data-slide-index="0" href="">tao</a>
            <a data-slide-index="1" href="">miori</a>
        </div>
        <ul class="bxslider">
            <li id="tao"><img src="http://koi-navi.net/wp-content/uploads/2015/10/5e9dd24e-e1444440113499.jpg"> </li>
            <li id="miori"><img src="http://images.ciatr.jp/2015/12/09202601/05c36a2c5ba65065ac4f2a6f6c75b3e1_55.jpeg"></li>
        </ul>  <!-- bxslider -->

        <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
        <script src="/jquery.bxslider/jquery.bxslider.min.js" type="text/javascript" ></script>}
        <script type="text/javascript">
            $(document).ready(function () {
                $('.bxslider').bxSlider({pagerCustom: '#bx-pager'});
                /*$('dd#miori').on('click', function () {
                    alert("hello");  // what should I write here?
                });*/
            });
        </script>

    </body>
</html>