Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

color codes in textarea using jquery

Is it possible to color the user entering code (inside a textarea) using jquery.

Specific texts like <h1>, <b> etc should be colored or highlighted.

this helps to distinguish the opening closing tags.

Please help

like image 388
Aakash Chakravarthy Avatar asked Jun 17 '10 15:06

Aakash Chakravarthy


2 Answers

No.
Text blocks in <textarea> elements cannot be formatted.

You need to use a ContentEditable element.
Try CodeMirror.

like image 111
SLaks Avatar answered Oct 06 '22 02:10

SLaks


jQuery will only be able to edit the styles of elements that can be styled using CSS. It is not possible to edit colours inside an input element in this way.

You might want to check out

SyntaxHighlighter

http://alexgorbatchev.com/wiki/SyntaxHighlighter

like image 24
calumbrodie Avatar answered Oct 06 '22 03:10

calumbrodie