Is there any good and logical ways to highlight code inside textarea via jQuery? If there is, please share.
You could use CodeMirror http://codemirror.net/
...a versatile text editor implemented in JavaScript for the browser. It is specialized for editing code, and comes with a number of language modes and addons that implement more advanced editing functionality.
A rich programming API and a CSS theming system are available for customizing CodeMirror to fit your application, and extending it with new functionality...
No, there isn't. You can apply styles to the entire textarea, but not part of the text in it.
You would need something that works as a replacement for the textarea, here is a list of some.
You can highlight a part of a text with the follow search code:
<script type="text/javascript">
$(document).ready(function() {
$("textarea").highlightTextarea({
words: ["first word","an other word"]
});
});
</script>
Find more about highlighting in a textarea on Highlight text into a textarea
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With