I know this question has already been asked but mine is a little different.
I have a textarea whose value I have set like so:
<textarea><span>all this inside textarea</span></textarea>
now i am doing some ajax with jQuery and want to set the value of the textarea via jQuery.
Following is my jQuery code.
jQuery(function(){
jQuery("select#rooms").change(function(){
var options = '';
jQuery.getJSON("/admin/selection.php",{id: jQuery(this).val(), ajax: 'true'},
function(j){
for (var i = 0; i < j.length; i++) {
options = j[i].topImage;
jQuery('#toppic').val(options);
jQuery('#title').val(j[i].title);
alert(j[i].content); //this is text area content. it has html tags
jQuery('#content').attr(j[i].content); //text area
}
})
})
})
EDIT: my json response is:
[ {topImage: 'cfil823', title: 'Dining', content: '<SPAN STYLE= "" >Dining Rooms must be simultaneously inviting enough for a festive Sunday brunch and intimate enough for a
crown jewel in the room. </SPAN>'}]
is there a way in jquery to escape html tags?
Also, initially the textarea was set like this:
<textarea id="content" wrap="hard"><?php echo $comma_separated?></textarea>