0

I have a script of audioplayer, I need to replace it to play/pause icons in mobile version and I did it, but I need to disable audioplayer.js in mobile version. In computer version I need audioplayer.js, but in mobile No. How can I disable script? I tried to use this:

$(window).resize(function(){
    if($(this).width() < 494) {
      $('#script').attr('src', '')
      console.log($('#script').attr('src'));
    }
    else {
      $('#script').attr('src', 'js/audioplayer.js');
      console.log($('#script').attr('src'));
    }
 })

but it did not help me. I need to disable script only in mobile version.

Full sample here

0

1 Answer 1

1
if (window.matchMedia("(min-width: 480px)").matches) {
  document.write('<script type="text/javascript" src="js/audioplayer.js"></script>');
}

You can use this to prevent including audioplayer.js on mobile devices

Sign up to request clarification or add additional context in comments.

1 Comment

it did not help( there are some problems with quotes

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.