title: jQuery add class based on html
body: <p>This is my HTML structure.</p>
  
  <pre><code>&lt;a href="www.example.com" rel="group-1" class="project"&gt;
      &lt;img src="http://www.example.com/image.png"&gt;
  &lt;/a&gt;
  &lt;div class="data"&gt;
      &lt;span class="media"&gt;http://www.example.com/video.mp4&lt;/span&gt;
      &lt;div class="desc"&gt;
          &lt;p&gt;asdfs&lt;/p&gt;
          &lt;a href="http://www.example.com/link"&gt;view link&lt;/a&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I want to use jQuery to attach a class onto the  tag based upon the HTML from the media class (span.media) in its sibling div (div.data)</p>
  
  <p>For example:<br>
  The above HTML would attach "video" to the  tag based upon the ".mp4"<br>
  If it was <code>http://www.example.com/image.jpg</code> or <code>http://www.example.com/image.png</code> then it would attach "image" to the class.</p>