Monday, March 21

Jquery, Get a block of html in a variable.

I came across this situation where , i had to get a block of html code to store in a variable, along with the html off-course. I was using, jquery. you can do this using a simple jquery function html().
For eg. if your code is

<div id="mycode">
<p>My description</p>
</div>

Then your jquery code should be

var data = $("#mycode").html();
This snippet saved me a lot of time and i could achieve the requirement.

Be the first one to Comment!!!

Post a Comment