Is there a style selector in jQuery?

Not necessarily a great idea, but you could add a new Sizzle selector for it :

$.expr[':'].width = function(elem, pos, match) {
    return $(elem).width() == parseInt(match[3]);
}

which you could then use like so:

$('div:width(970)')

That’s going to be horrifically slow, though, so you’d want to narrow down on the number of elements you’re comparing with something like :

$('#navbar>div:width(970)')

to only select those divs that are direct descendants of the navbar, which also have a width of 970px.

Leave a Comment