rotation - jQuery - Simple Text Rotator with click event -


i using simple text rotator , fantastic, issue have click event have not working it:

$(function() {         $('a[href*=#]:not([href=#])').click(function() {         if(!$(this).hasclass('carousel-control')){                 if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {                     var target = $(this.hash);                     target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');                     if (target.length) {                             $('html,body').animate({                                 scrolltop: target.offset().top - topsize                             }, 2000);                             return false;                     }                 }            }         });     }); 

when click on link in text rotator not scroll, goes id section (for #link-1 & #link-2) ( link-3.php , link-4.php work fine because going page)

 <h1 class="sliding-text">         <span class="rotate">             <a href="#link-1">link 1</a>,              <a href="#link-2">link 2</a>,             <a href="link-3.php">link 3</a>,             <a href="link-4.php">link 4</a>         </span>     </h1>      $(".sliding-text .rotate").textrotator({         animation: "fade",         speed: 1000     }); 

and here jquery code library:

!function ($) {      var defaults = {         animation: "fade",         separator: ",",         speed: 2000     };      $.fx.step.textshadowblur = function (fx) {         $(fx.elem).prop('textshadowblur', fx.now).css({ textshadow: '0 0 ' + math.floor(fx.now) + 'px black' });     };      $.fn.textrotator = function (options) {         var settings = $.extend({}, defaults, options);          return this.each(function () {             var el = $(this)             var array = [];             $.each(el.html().split(settings.separator), function (key, value) {                 array.push(value);             });             el.html(array[0]);              // animation option             var rotate = function () {                 switch (settings.animation) {                      case 'fade':                         el.fadeout(500, function () {                             index = $.inarray(el.html(), array)                             if ((index + 1) == array.length) index = -1                             el.text(array[index + 1]).fadein(settings.speed);                         });                         break;                 }             };             setinterval(rotate, 8000);         });     }  }(window.jquery); 

how click event work text rotator

i don't think it's working because text rotator plugin removing , adding links in dom. can around using delegated event binding, follows:

$(function() {   $('.sliding-text').on('click', 'a[href*=#]:not([href=#])', function() {     // .. code here   }); }); 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -