How would you find using jQuery an element with maximal “page” value which is less than “6” ?
Suppose that “page” has only numerical values, and that the elements are sorted by “page”. For example:
<div id="wrapper">
<div page="1"></div>
<div page="2"></div>
<div page="4"></div> => answer
<div page="6"></div>
<div page="7"></div>
<div page="9"></div>
</div>
You can use filter to select all the selectors less than 6, and then select the last one.
example: http://jsfiddle.net/niklasvh/rFYfM/