title: Setting background image of div using a variable URL (jQuery)
body: <p>I'm creating a user signup page and I want the user to be able to enter an image URL and then preview the image in a reserved div (which has a default image in it already, applied by a given class). My HTML for the user image display is:</p>
  
  <pre><code>&lt;div id="user-image-preview" class="col-md-4 col-sm-12 user-image-preview"&gt;  &lt;/div&gt;
  &lt;button id="preview-image"&gt;Preview image&lt;/button&gt;
  </code></pre>
  
  <p>The CSS for id'user-image-preview' and class 'user-image-preview' are:</p>
  
  <pre><code>#user-image-preview {
  height: 300px;
  width: 300px;
  border-radius: 50%;
  position: absolute;
  left: 200px;
  top: 150px;
  background-size: cover;
  }
  
  .user-image-preview {
  background-image: url("https://cdn1.iconfinder.com/data/icons/unique-round-blue/93/user-512.png");
  background-size: cover;
  }
  </code></pre>
  
  <p>Here is the input part of the form where user inputs image URL:</p>
  
  <pre><code>&lt;div class="form-group"&gt;
      &lt;i class="fa fa-picture-o" aria-hidden="true"&gt;&lt;/i&gt;
      &lt;label for="img"&gt;Image&lt;/label&gt;
          &lt;input id="user-image-set" type = "text" class ="form-control" placeholder = "Enter image URL" name = "image"&gt;
   &lt;/div&gt;
   &lt;button id="submit-login" type ="submit" class="btn btn-primary btn-lg  disabled"&gt;Signup&lt;/button&gt;
  </code></pre>
  
  <p>And then I wrote the following jQuery to remove the default image (class="user-image-preview") and then add whatever is in the input field:</p>
  
  <pre><code>$("#preview-image").on("click", function() {
  var newUserImage = $('#user-image-set').val();
      $("#user-image-preview").removeClass("user-image-preview");
      $("#user-image-preview").css("background-image", "url('newUserImage')");
      console.log(newUserImage)
  })
  </code></pre>
  
  <p>(I added the console.log just to check if I am capturing the variable correctly which I am).</p>
  
  <p>I presume the is a problem with my use of quotes within the URL part of the function, but I can't quite work out what the correct way to cite this variable is.</p>