title: Jquery - Multiple elements with the same class but different IDs to use the same function by with different results
body: <p>I am working on a music site that would like the the album covers as links to the track listings for that particular release.</p>
  
  <p>My issue with having an image link would mean I would not be able to put any sort of descriptive text accompanying the image, unless it was an overlay, a tooltip or it to appear just below or somewhere around the image.</p>
  
  <p>It is very possible to achieve a similar effect I am trying to achieve with PHP (the site would be running on WP), but that may be an issue with download speeds, screen sizes.</p>
  
  <p>So I am wondering if such an effect can be achieved using JQuery.</p>
  
  <p>Here is a basic structure of what I am looking to do.</p>
  
  <p>This would be how the HTML looks for each release link:</p>
  
  <pre><code>&lt;div class="box cover" id="uni-123"&gt;
      &lt;a href="hover" id="page-title"&gt;This is the text&lt;/a&gt;
  &lt;/div&gt;
  
  &lt;div class="box cover" id="uni-124"&gt;
      &lt;a href="hover" id="page-title-2"&gt;This is the text&lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Style would get the sizing correct for the imagery...</p>
  
  <pre><code>.box {width: 200px; height: 200px; border: 1px solid black;}
  .box a {display: block; width: 200px; height: 200px; color: white;}
  </code></pre>
  
  <p>And then the JQuery would use the unique id's of each box to determine which imagery to get...</p>
  
  <pre><code>function boxImage(){
  var boxId = $('.box').attr("id");
  var image = $('#' + boxId + ' &gt; a ').attr("id");
      $('#' + boxId).css({"background":"url(" + image + ".jpg)","background-size":"contain"});
  }
  
  $(document).ready(boxImage);
  </code></pre>
  
  <p>Obviously the trouble I am having is that the imagery only shows up on the first instance of .box, not all of them... SO is there a way for the boxImage function to take effect on all instances rather than on just the first... and if so... HOW?</p>
  
  <p>Thanks in advanced, Matt</p>