Skip to main content

Tedshd's Dev note

JavaScript - handle textarea value

Table of Contents

# JavaScript - handle textarea value

Handle textarea string.

// jQuery
var textarea = $('textarea').val().replace(/\n/g, '<br>');
// JavaScript
var textarea = document.querySelector('textarea').value.replace(/\n/g, '<br>');