- This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
Viewing 5 posts - 1 through 5 (of 5 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › Jqurey append html as text to textarea
Hi
I am trying to make a link which once clicked will add text to the text area/field. The text needs to be pure text (HTML not translated).
So I got two pieces of jquery code which I struggling to make work together to achieve what I want.
To make HTML be plain text I have this code:
var text = document.createTextNode('MyText
');
document.body.appendChild(text);
And to append the
MyText
to the text area I have a rough idea, like this:
$("#answer1").click(function(){
$('ul li').append('✓');
});
(found on internet)
Now can anyone help me structure this code to function the way I want, please?
Regards
Aleksander
$(function() {
$('#answer2').click(function() {
var content = '✓ TADAAA!';
$('textarea').append(
content
.replace(/&/g, '&')
.replace(/
.replace(/>/g, '>')
);
});
});
ohh, but it doesn’t work once you type something in… any ideas?
Try this:
$('#answer2').live('click', function(){});
instead of this:
$('#answer2').click(function(){});