user2178521
user2178521

Reputation: 843

How to append text on select text inside of textarea

I have try to use jquery create a simple rich text,

$('#textarea').bind('keyup', function(e) {
  var data = $('#textarea').val()
  $('#data').html(data.replace(/\n/g,"<br />"));
});

$('#bold').click();

anyone know how to append text on select text inside of textarea(append front and back) ex. append <b>select text</b> and don't show any tag inside of textarea <b>

http://jsfiddle.net/KnyTt/

Upvotes: 0

Views: 472

Answers (1)

nondefault
nondefault

Reputation: 377

See my answer here on how to format selected text. Unfortunately, an HTML textarea component simply won't display HTML formatted text. You could certainly check out some HTML/JS rich text editor components such as TinyMCE instead of trying to write your own.

EDIT: You could apply my above answer to an editable div (or some other element that displays formatting) using @elclanrs link.

Upvotes: 1

Related Questions