Treehouse: Grow your CSS skills. Land your dream job.

Jqurey append html as text to textarea

  • # July 20, 2012 at 9:32 pm


    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('



    And to append the


    to the text area I have a rough idea, like this:

    $('ul li').append('✓');

    (found on internet)

    Now can anyone help me structure this code to function the way I want, please?


    # July 21, 2012 at 12:34 am
    $(function() {
    $('#answer2').click(function() {
    var content = '✓ TADAAA!';
    .replace(/&/g, '&')
    .replace(/ .replace(/>/g, '>')

    # July 22, 2012 at 6:28 pm

    @Hompimpa Thank you!! worked perfectly.

    # July 22, 2012 at 6:29 pm

    ohh, but it doesn’t work once you type something in… any ideas?

    # July 23, 2012 at 4:08 am

    Try this:

    $('#answer2').live('click', function(){});

    instead of this:

    # July 23, 2012 at 5:26 am

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.