The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript [Solved] jQuery append text to textarea

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #30579

    Hey guys, I have a little script here to make links.

    it has two input textareas which will take the link and text inputted and make a shortcode for a user.

    My jQuery is as follows:

    var link = $('#link').val();
    var text = $('#linkText').val();
    $('#edit').append("n" +'[link:' +text +'|' +link +']');

    It works fine…. Up until I edit anything in the textarea manually, then the code doesn’t want to append the text to the textarea. I have a live version on my test site right now. Any help would be appreciated. Thanks.

    Chris Coyier

    is the .append() the problem? Usually textareas are edited by using .val() to change the current value. You could pull in the current value, append, and put back.

    var $edit = $("#edit");
    var curValue = $edit.val();
    var newValue = curValue + "whatever new stuff here";
Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.