var arrInput = ['4','5','17']; arrInput =''+arrInput.map(function(a) { return ':contains('+a+')' }) ; alert(arrInput)