goalie35
goalie35

Reputation: 786

jQuery: return string as html

I have a "Label" control on my form which is being populated via jquery. My problem however, is I need to return my string with html tags, but my label doesn't seem to recognize html. Here's my control:

<label id="comment"></label>

And here's how I'm working with it in javascript:

var comment;
comment = $("#comment");
comment.text("<b>Please scan an <br/>item!</b>");

In the above code, the html in my string is ignored. Is there any way I can get my form to recognize the returned html tags?

Thanks

Upvotes: 0

Views: 3608

Answers (3)

Robert Wilson
Robert Wilson

Reputation: 669

comment.html("<b>Please scan an <br/>item!</b>");

Upvotes: 0

Tschallacka
Tschallacka

Reputation: 28722

try comment.html("<b>Please scan an <br/>item!</b>");

You could also use document.getElementById("comment").innerHTML = "<b>Please scan an <br/>item!</b>";

Upvotes: 3

Denys S&#233;guret
Denys S&#233;guret

Reputation: 382150

Use the html function :

comment.html("<b>Please scan an <br/>item!</b>");

Upvotes: 6

Related Questions