malsup / cycle2

2nd gen cycling
899 stars 236 forks source link

add 'cycle-pager-active' class to the element prev() to the current slide #636

Open anointybird opened 9 years ago

anointybird commented 9 years ago

Hello! I'm trying to add 'cycle-pager-active' class to the element prev() to the current slide. It is so the same image-icon is highlighted for two slides instead of one. Desired: user slides to 'longer-life2' and 'thumb-longer-life' is highlighted. My code seems to be working, except that it after it gets added, it is instantly removed. Thanks!

<div class="thumbnail-nav">
        <div id="no-template-pager" class="cycle-pager external">
            <!--INTRO-->
            <img id="thumb-intro" src="img/on-intro.png">
            <!--TOC-->
            <img id="thumb-toc" src="img/on-toc.png">
            <img id="thumb-longer-life" class="" src="img/on-love.png">
            <p id="thumb-longer-life2" class="hs"></p>

jQuery(function($) {
  function updateHash() {
    if((document.location.hash === "#longer-life")|| (document.location.hash === "#longer-life2")) {
        $('.prevnext-div a').attr('class', 'blue');
        $('#thumb-longer-life').addClass('cycle-pager-active');
    }