$("input").keyup(function(){ var target = $(this).attr('id'); var text = $(this).val(); $("."+ target).text(text); });