How do I make a property bold when displayed in a textarea in jquery?

I need to make part of the text bold when displayed in jquery:

$(':checked').each(function() {
    var $textarea = $('textarea');
    $textarea.val($textarea.val() + $(this).prop('name') + ' = ' + this.value + '\n' );
});

      

In the above code, I want to make $ (this) .prop ('name') bold while it is being displayed in textarea.

Please give me suggestion / help

Thanks in advance Ramsai

+3


source to share


2 answers


The text inside the textbox cannot be bold as far as I know because markup is required to make the text bold and the textbox is not rendered (unless you are using a WYSIWYG plugin like Tiny MCE).
You can do something like stackoverflow which has a preview pane where the text is previewed with markup



+2


source


You cannot change the formatting of individual characters within the display textarea

.



However, you can use div

(for example) and set its attribute contenteditable

, which allows, for example, to make certain words bold. However, this is much more complicated than textarea

.

+2


source







All Articles