jQuery addClass example
Change class name on click in jQuery
by Sedbol
HTML
<textarea id="textField"></textarea>
<div id="hey" messag="Первый текст," >Первый текст</div>
<div id="hey" messag="Второй текст," >Второй текст</div>
CSS
#hey{
cursor: pointer;
}
JavaScript
$('#hey').on('click', function () {
var name = $(this).attr('messag');
$('#textField').val(name);
});
$('#textField').on('input', function(e) {
this.style.height = '1px';
this.style.height = (this.scrollHeight) + 'px';
});