title: How do you prevent jQuery code executing on a mobile device?
body: <p>I'm currently working on building a site with a responsive design. As part of that I need to prevent the below code from executing if the user visits the website using a mobile device. How can I achieve that?</p>
  
  <p>The code:</p>
  
  <pre><code>var leftHeight = $("#sidebar").height();
  var rightHeight = $("#main").height();
  if (leftHeight &gt; rightHeight){ $("#main").height(leftHeight)}
  else{ $("#sidebar").height(rightHeight+25)};
  
  function equalHeight() {
      var heightArray = $("#footer&gt;div.box").map(function () {
          return $(this).height();
      }).get();
  
      var maxHeight = Math.max.apply(Math, heightArray);
      $("#footer&gt;div.box").height(maxHeight);
  }
  equalHeight();
  </code></pre>