Creating new selectors is kind of fun, so I did that:
Usage:
:hasCssAttr(property, value ...)
Property
is the css property you would like use to compare
value
is the value(s) you would like to match against (you can have more than one)
$(':hasCssAttr(float, left)').css('float', 'right');
The source Luke:
$.expr[':'].hasCssAttr = function(objNode, intStackIndex, arrProperties, arrNodeStack) {
var arrArguments = arrProperties[3].split(',');
var cssPropVal = $(objNode).css(arrArguments[0]); // need for speed
for (var i = 1 ; i < arrArguments.length ; i++)
if (cssPropVal == arrArguments[ i ].replace(/^\s+|\s+$/g,""))
return true;
return false;
}
Basically, this selects any ol' css property. I suppose you could eliminate the loop if you only wanted one value, kind of unnecessary. Also, I wonder if it might be more interesting to do this in an eval so you could do numerical comparisons. Anyway. There it is.
Props to Ben for helping me out.