Reputation: 47595
I have this, and it works:
local.Source = $('article.hero-unit').html();
$('#Source').text(local.Source);
But what I'd like to do is this:
local.Source = $('article.hero-unit').html();
$('fieldset').append(local.Source);
The problem is that the append method appends the html and doesn't escape the < symbol.
Upvotes: 0
Views: 41
Reputation: 47595
I think this does the trick:
local.Source = $('article.hero-unit').html();
local.Legend = $('fieldset legend').text();
$('fieldset').text(local.Source);
$('fieldset').prepend('<legend>' + local.Legend + '</legend>');
Upvotes: 0
Reputation: 298076
I would put that text into a <span>
element:
$('<span>', {
text: local.Source
}).appendTo('fieldset');
Upvotes: 1
Reputation: 276286
Try
local.Source = $('article.hero-unit').html();
var $fieldset = $('fieldset');
$fieldset.text($fieldset.text()+local.Source);
Calling .text()
without parameters grabs the text already in the element. All this does is add the html of local.Source
to it
Upvotes: 1