title: Selecting first visible element with classname
body: <p>I'm trying to select the first element with a specific class that is also visible. I only want to select the one element and store it as a variable.</p>
  
  <pre><code>var elements = document.getElementsByClassName('className'); // Get all visible elements with classname.
  var element= elements[0]; // Return only the first element from this NodeList
  </code></pre>
  
  <p>For my specific use case, I'm attempting to then retrieve its background image, so this is what I've got so far. My variable returns "undefined".</p>
  
  <pre><code>var bg = element.css('background-image'); // Returns url('http://www.google.com/imageurl')
  </code></pre>
  
  <p>I'm using jQuery, but plain JavaScript is welcome, too. Whatever gets the job done the best.</p>