The simplest solution is programmatic. No native jQuery selectors will do this however you can write your own. You can then write:
$("div:larger(100x100):smallest")...
It creates four selectors (only two of which are needed for this problem, the others are for completeness):
:larger(HxW)
:smaller(HxW)
:largest
:smallest
Source code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
$("div:larger(100x100):smallest").css("border", "1px solid black");
});
$.extend($.expr[":"], {
smaller: function(elem, i, match) {
var m = /^(\d+)(?:x(\d+))$/.exec(match[3]);
if (!m) {
return false;
}
var h = m[1];
var w = m[2] || h;
var t = $(elem);
return t.height() <= h && t.width() <= w;
},
larger: function(elem, i, match) {
var m = /^(\d+)(?:x(\d+))$/.exec(match[3]);
if (!m) {
return false;
}
var h = m[1];
var w = m[2] || h;
var t = $(elem);
return t.height() >= h && t.width() >= w;
},
smallest: function(elem, i, match, set) {
var areas = $.map(set, function(elem, index) {
return $(elem).height() * $(elem).width();
});
for (var j=0; j<areas.length; j++) {
console.log("" + j + ": " + areas[i] + " / " + areas[j]);
if (areas[j] < areas[i]) {
return false;
}
}
return true;
},
largest: function(elem, i, match, set) {
var areas = $.map(set, function(elem, index) {
return $(elem).height() * $(elem).width();
});
for (var j=0; j<areas.length; j++) {
if (areas[j] > areas[i]) {
return false;
}
}
return true;
}
});
</script>
<style type="text/css">
div { background: yellow; margin: 15px; }
#one { height: 50px; width: 50px; }
#two { height: 100px; width: 100px; }
#three { height: 150px; width: 150px; }
</style>
</head>
<body>
<div id="one"></div>
<div id="two"></div>
<div id="three"></div>
</body>
</html>