[Solved] javascript variable > than number


If your goal is to find all matching divs, you have to do a bit more work. Not a lot, but a bit:

var w = 1600;
var h = 1063;
// Find all divs and filter them
var matchingDivs = $("div").filter(function() {
    // Does this div's text match the form (1601 x 1064)?
    // If so, grab the numbers.
    var match = /^\((\d+) x (\d+)\)$/.exec($(this).text());
    if (match) {
        // Yes, it does, do the numbers fit?
        if (parseInt(match[1], 10) > w && // [1] = the first capture group
            parseInt(match[2], 10) > h) { // [2] = the second capture group
            // Keep this div
            return true;
        }
    }

    // Don't keep this div
    return false;
});

7

solved javascript variable > than number