Q:

jQuery - If previous element doesnt have specific class then remove that element

I wrote this code, but it doesnt work.
goal: 

If span that is previous to ".well-well" is NOT ".dont-remove" then remove that span
However if span that is previous to ".well-well" IS ".dont-remove" then do nothing

"example" here:
http://jsfiddle.net/sAebR/
if( $(".well-well").prev('span').not('.dont-remove') ){ $(".well-well").prev('span').remove(); }

What im getting with this code is that it removes all spans that are previous to ".well-well" and i have no idea why.
What am i doing wrong?

A:

you don't need the if:
$(".well-well").prev('span').not('.dont-remove').remove()

what your code is say is:
if ($(".well-well").prev('span').not('.dont-remove') != null) 
{
 //remove them all
}

don't worry about the if. The remove() function will look after that.
http://jsfiddle.net/sAebR/2/

