Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add text to textarea - Jquery

How can I add text from a DIV to a textarea?

I have this now:

    $('.oquote').click(function() {        $('#replyBox').slideDown('slow', function() {       var quote = $('.container').text();             $('#replyBox').val($('#replyBox').val()+quote);            // Animation complete.       });         }); 
like image 754
Oliver 'Oli' Jensen Avatar asked Aug 14 '11 18:08

Oliver 'Oli' Jensen


People also ask

How do I add text to textarea?

To add text to a textarea, access the value property on the element and set it to its current value plus the text to be appended, e.g. textarea. value += 'Appended text' . The value property can be used to get and set the content of a textarea element.

How to append value to textarea in jQuery?

it has two input textareas which will take the link and text inputted and make a shortcode for a user. var link = $('#link'). val(); var text = $('#linkText').

How do I get inner text in jQuery?

Answer: Use the jQuery text() method You can simply use the jQuery text() method to get all the text content inside an element. The text() method also return the text content of child elements.


1 Answers

Just append() the text nodes:

$('#replyBox').append(quote);  

http://jsfiddle.net/nQErc/

like image 50
AlienWebguy Avatar answered Sep 24 '22 07:09

AlienWebguy