var classArray = $('input').attr('class').split(' '); // So now you can declare variables var classbtn1 = classArray[0]; var classbtn2 = classArray[1];