Skip to content

Instantly share code, notes, and snippets.

@cjwinchester
Created December 9, 2013 05:43
Show Gist options
  • Save cjwinchester/7867788 to your computer and use it in GitHub Desktop.
Save cjwinchester/7867788 to your computer and use it in GitHub Desktop.
Add paragraph tags to textarea input
// add <p> tags to a textarea input
function addGrafs() {
var dt = document.getElementsByTagName("textarea")[0];
dt.value = '<p>' + dt.value.replace(/\n/g, '</p>\n\n<p>').replace(/\n\n<p><\/p>/g, '') + '</p>'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment