You can do something like the following:
$(".word, #desc, #title...").keyup(function () {
var word = $(this).val();
$("."+$(this).attr('id')+"_preview").html(word);
return false;
});
Change . As suggested by Andrew, there is no need to use a jQuery wrapper:
$(".word, #desc, #title...").keyup(function () {
var word = this.value;
$("."+this.id+"_preview").html(word);
return false;
});
Thank you Andrey!
source
share