For elements, <input type="text" />you can simply use the attribute maxlength.
, <textarea>, onkeyup .
$('.shortened')
.keyup(function(e){
var $this = $(this);
$this.text($this.text().substring(0, max));
});
, , , .
$('.shortened')
.each(function(){
var remainTxt = $(this).text().substring(max, $(this).text().length);
$(this).text($(this).text().substring(0,max));
});
: Mark, .text() , "expand".