 <p>You have to use <a href="http://api.jquery.com/filter/" rel="nofollow"><code>.filter</code> <em><sup>[docs]</sup></em></a>:</p> <pre class="lang-js prettyprint-override"><code>$('img').filter(function() { return this.src === $(this).attr('rel'); }); </code></pre> <p>Note that <code>rel</code> is not a valid attribute for <code>img</code> elements. Therefore you might want to use <a href="http://ejohn.org/blog/html-5-data-attributes/" rel="nofollow"><code>data-*</code> attributes</a> to store the additional information.</p> <p><strong>Additional note</strong>: <code>this.src</code> will return the <em>absolute</em> URL, even if the <code>src</code> attribute contains a relative URL. If you want to get the actual value of the attribute, you have to use <code>$(this).attr('src')</code>.</p>