Use jQuery's filter/map function to support legacy browsers.