title: I want to use JavaScript to change the background image on a website when the device is small
body: <p>I built a webpage with a Parallax feature.  I used javascript to disable the text part on small screens, but there is no picture.  I want to use JavaScritp to swap the larger picture (1500pixels) for a smaller one(500px).  I copied the class in called home, changed the name to mobilehome and added the smaller image.  Here is the code javascript:</p>
  <pre><code>/* disable paralax scrolling */
  var ismobile = /Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera 
  Mini/i.test(navigator.userAgent)
  if (ismobile){
  
   // bypass parallax effect
   background()
   }
  
    //change background pictures
    function background () {
    var background1 = document.getElementById(&quot;home&quot;);
    background1.target.classlist(&quot;mobilehome&quot;)};
  </code></pre>
  <p>It doesn't work, any advice?</p>