Cam Cam
Cam Cam

Reputation: 75

Jquery show HTML Tags not a results of this tag?

Why after this script:

$("<span />", { text: this.value+' <br /><br />', "class":"view" }).insertAfter(this);

I see text <br /><br />. I want to see results not a HTML tags.
Plz any help

Upvotes: 0

Views: 54

Answers (2)

Afzaal Ahmad Zeeshan
Afzaal Ahmad Zeeshan

Reputation: 15860

Replace your value to this:

html: this.value + ' <br /><br />', "class": "view"

Why?

Because you are updating the text which is the visible value of the element.

Using html you will write the value next to it, as the HTML content. And the <br /> will be used as a line break.

Upvotes: 0

Use html

$("<span />", { html: this.value+' <br /><br />', "class":"view" }).insertAfter(this);
              //^

Read What is the difference between jQuery: text() and html() ?

.html()

Upvotes: 1

Related Questions