You could use an "attribute contains" selector (*=
):
var imgs = $('img[style*="float: right"], img[style*="float:right"]');
(Note I've allowed for there being a single space, or not.) But it seems quite delicate and may be slow (doesn't really matter if you do it once, might matter if you do it a lot). Instead, I'd probably add a class to the relevant images. This will be faster on modern browsers than the each
loops other answers suggest, however, as the work can be done within the browser's selector engine rather than in the JavaScript layer.
Also note that that will only match if the actual img
tag has float: right
within its style
attribute.