jQuery :not/.not filter not behaving properly
<p>So i was trying to append some code to all my images(for a rollover) in a certain portion of my document via javascript (primarily for graceful degredation purposes)etc and so</p>

<p>after noticing my function not work...i wrote a super small function to test it and no good. In this example, what im trying to do is alert an images alt tag but <strong>not</strong> a specific button div. Essentially, apply said function to all images in a parent div (portSecW) and not the close buttons image/div.</p>

<p>so for the sake of this example, heres some HTML(pseudo):</p>

<pre><code>&lt;div id="portSecW"&gt;
  &lt;img src="X" alt="something here"&gt;&lt;/img&gt;
  &lt;img src="a" alt="something here"&gt;&lt;/img&gt;
  &lt;img src="b" alt="something here"&gt;&lt;/img&gt;
  &lt;div class="closeXbtn"&gt;&lt;img src="g" alt="something here"&gt;&lt;/img&gt;&lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>Here is what ive tried.</p>

<pre><code>$('#portSecW img:not(".closeXbtn")').click(function(){
    alert($(this).attr("alt")); 
    return false;
});
</code></pre>

<p>Ive also gone about it like this</p>

<pre><code>$('#portSecW img').not('.closeXbtn').click(function(){
    alert($(this).attr("alt")); 
    return false;
});
</code></pre>

<p>ive also tried like this but doesnt work (so im assuming that although i get no errors, its not constructed properly because the alert function doesnt fire.)</p>

<pre><code>$('#portSecW img.not(".closeXbtn")').click(function(){
    alert($(this).attr("alt")); 
    return false;
});
</code></pre>

<p>So not sure what im doing wrong. </p>

<p>Thanks in advanced.</p>

<p><strong>NOTE:</strong> Just incase anyone is looking, the marked ""accepted answer" worked for me but upon further digging. all of my tries above worked, the problem was i wasnt precise enough with how i traversed the DOM. So all of these do the same thing and work. here are the changes i made and again, these all worked.</p>

<pre><code>$('#portSecW a').children('img').click(function(){
    alert($(this).attr("alt")); 
    return false;
});

$('#portSecW img').not(".closeXbtn img").click(function(){
    alert($(this).attr("alt")); 
    return false;
});

$('#portSecW img:not(".closeXbtn img")').click(function(){
    alert($(this).attr("alt")); 
    return false;
});
</code></pre>

<p>Thanks Everyone for your help</p>
