var select = [ 12, 13, 0, 18 ]; $('path').filter( handler ).attr('fill', '#52BAED'); function handler( index ){ return select.indexOf( index ) != -1; };