0

I'm trying to get a jQuery function disabled on a mobile version, I followed the instructions -> here

However it doesn't work, here is my code:

var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ? true : false;
jQuery(document).ready(function(e) {
 jQuery("body").mousemove(function(e) {
  if(!isMobile) {
    e.preventDefault();
    dataslide = $(this).attr('.nk-navbar-default');
    goToByScroll(dataslide);
  }
 jQuery(".nk-navbar-default").css( "opacity", "0.8");
  setTimeout(function(e){
  jQuery(".nk-navbar-default").css( "opacity", "0");
  }, 2000);
 });
});

Best!

Omar
  • 32,302
  • 9
  • 69
  • 112
Websizeme
  • 3
  • 3

1 Answers1

0

Found my issue... Here is the solution (wrong condition):

var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ? true : false;
jQuery(document).ready(function(e) {
 jQuery("body").mousemove(function(e) {
  if(!isMobile) {
   jQuery(".nk-navbar-default").css( "opacity", "0.8");
   setTimeout(function(e){
    jQuery(".nk-navbar-default").css( "opacity", "0");
   }, 2000);       
  }
 });
});
Websizeme
  • 3
  • 3
  • Unsolicited advice: your ternary conditional is redundant. The `test` function already returns the boolean you need: `var someBool = /foo/i.test(bar)`. – shabs Sep 18 '17 at 16:05