Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

195
Views
JavaScript hover effect preventing link from working in Safari

I am using the exact code from [this CodePen][1] to create a text distortion hover effect.

https://codepen.io/willynogs/pen/pEyjpx

My issue is that in Safari it takes multiple clicks of the link to actually navigate to the destination. In Chrome it works fine on first click.

This problem can be replicated directly in the CodePen.

Please advise how I might be able to fix this so that the anchor link works across browsers.

Thanks!

$(function(){
  //DECLARE GLOBAL VARIABLE FOR USE IN HANDLERS
  var orig, sib;
  var runs = 0;
  var charSet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890+>?-$#@%&*';
  
  //RUN JS WHEN 'DISTORT' IS HOVERED
  $('.distort').hover(function(){
      var curr = $(this);
      orig = $(this).text();
      sib = setInterval(function(){
        distortText(curr);
      }, 100);
  }, function(){
    //RESET THE ORIGINAL TEXT
    clearInterval(sib);
    $(this).text(orig);
  });
 
  function distortText(i){
    //MAINTAINS SOME READABILITY IN THE TEXT BY ONLY ALLOWING 3 CHARACTERS TO BE DISTORTED
    if (runs >= 2){
      runs = 0;
      i.text(orig);
      return;
    }
    //GET EACH INDIVIDUAL CHARACTER
    var chars = i.text().split('');
    //GET A RANDOM CHARACTER FROM THE TEXT
    var rand = Math.floor(Math.random() * (chars.length));
    //GET A RANDOM REPLACEMENT CHARACTER
    var randRep = Math.floor(Math.random() * (charSet.length));
    //CHECK TO MAKE SURE THAT THE NEW CHARACTER IS DIFFERENT FROM THE OLD
    if(chars[rand] != charSet[randRep] && chars[rand] != ' '){
      chars[rand] = charSet[randRep];
    } else {
      distortText(i);
    }
    //UPDATE TEXT
    i.text(chars.join(''));
    runs += 1;
  }
});```


  [1]: https://codepen.io/willynogs/pen/pEyjpx
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!