$(".people, .custom").on("click",clear); function clear(){ if ($(this).val() != "") $(this).val(""); } //This clears respective class elements when clicked