I am trying to work out how to write a function where I pass in a string and this string is added to a textarea. This I can do, but I want to parse that string and change the colour on different parts of the string.
In other words, find the words "select", "where" and turn them blue. Then find the words 开发者_开发技巧"AND", "OR", "<" and turn them grey and anything in between two single quotes to be the colour red.
I am hoping for a simple function rather than using syntax highlighting libraries, I am not even sure they will work with strings that are dynamically generated.
How can I do this? I am able to make use of JQuery if this makes things easier?
Thanks all
text inside <textarea>
elements is plain text only, meaning that it cannot be styled. what you can do is create a div with contenteditable
and work with that, check this link out for a reference: http://www.west-wind.com/Weblog/posts/778165.aspx
精彩评论