Display string in textarea using html / css style

I have a string containing the CSS style of the c font embedded in the string. I am using Razor and I want to show the result in a text box or something similar. Is there a good way to do this?

This is what the line looks like:

<font color="DD0000"><b>7/10/2014 - CFENDALL</b>&nbsp;&nbsp;Hi Mike - I have invoice 133528E for PO 158960 - This is past due - Please let me know when PO is received.  Thank you.  Cynthia</font>

I want the stylish version to appear in the text box, but now it just displays the string without using css.

Here is what I mean right now:

    <div class="editor-field" id="summary">
        @Html.TextAreaFor(model => model.Notes, new { @readonly = "readonly"})
    </div>
+4
source share
3 answers

A textarea ; . , ; . - div, .

Coyier , : http://css-tricks.com/textarea-tricks/.

, SO. , "" , div. Cue jQuery:

HTML:

<div id="fakeTextarea"></div>
<textarea id="realTextarea"></textarea>

JavaScript:

$('#fakeTextarea').html( $('#realTextarea').val() );

Fiddle.

+3

, . - :


HTML

<div class="messages"><code contenteditable="true"></code></div>

JScript

var messageBox = $('.messages code');

function sendMessage(message, color){
    var color = (typeof color === "undefined") ? "inherit" : color;
    var fullMessage = "<span style=\"color:" + color + "\">" + message + "</span>";
    messageBox.append(fullMessage);
    /*messageBox.scrollTop(messageBox[0].scrollHeight); keeps the area scrolled down */
}

/*You can call this like:*/
var message = "<b>7/10/2014 - CFENDALL</b> Hi Mike - I have invoice 133528E for PO 158960 - This is past due - Please let me know when PO is received.  Thank you.  Cynthia";

sendMessage(message, "#DD0000");

* CSS

Fiddle http://jsfiddle.net/G7BB9/3/

+1
textarea{
    color: #dd0000;
    font-weight: bold;
}

not sure if this is the answer you asked for, but it will be the way you create the text area. There are other really dirty positioning methods that you can use, but not recommended.

0
source

Source: https://habr.com/ru/post/1548395/


All Articles