You are viewing an old revision of this post, from April 22, 2016 @ 14:32:37. See below for differences between this version and the current revision.

jQuery – Get & format HTML tags from a simple string

I have a String variable say

strHTML = "<div class='abc'> This is a test <span class='xyz'> String </span> </div> "

that i m receiving from server. When I use

$('#container').append(strHTML);
or
$('#container').text(strHTML);

it is displaying the whole string including HTML tag in "container".

What i want is to take each HTML tag as HTML element in "Container" & apply class whever i defined in it..

 

Here is the solution i used to solve the issue:
I use another function, it is the function html(), it worked ^^
$("#container").html(strHTML);

Revisions

  • April 22, 2016 @ 14:32:37 [Current Revision] by admin
  • April 22, 2016 @ 14:32:37 by admin

Revision Differences

There are no differences between the April 22, 2016 @ 14:32:37 revision and the current revision. (Maybe only post meta information was changed.)

No comments yet.

Leave a Reply