Asaf
Asaf

Reputation: 8206

jQuery selector for bigger or smaller than

I have elements that I want to choose from,
and I want to choose only the elements that have margin-left
smaller than 100 pixels but bigger than 0.

Is that possible in jQuery?

Upvotes: 1

Views: 817

Answers (1)

Felix Kling
Felix Kling

Reputation: 816404

You can use filter (assuming elements is a jQuery object):

elements.filter(function() {
    var margin = parseInt(this.style.marginLeft, 10);
    return  margin > 0 && margin < 100;
}).something();

Upvotes: 4

Related Questions