append string to textbox contents?
14,952
Solution 1
use jquery .val to set the text box value , it should do it
Solution 2
pretty easy task with jQuerys .val()
help method:
$('button').click(function(event) {
$('input:text').val(function(index, val) {
return val + event.target.value;
});
});
Demo: http://www.jsfiddle.net/QFm7K/
Solution 3
or
$('button').click(function() {
$('textarea')[0].value += $(this).val();
});
Author by
nkcmr
Updated on June 04, 2022Comments
-
nkcmr almost 2 years
pretty simple, I have buttons but i want to add their value to a textbox when they are clicked, how would i go about doing this in jQuery? They are all numbers and their cant be more than 10 in the textbox.
-
Pointy about 13 yearsthe superscript link is cute :-)
-
jAndy about 13 yearsI INVENTED IT! ME ME ITS MEEE maybe patrick dw won't see this :p
-
Developer almost 11 yearsHi how can I use this when I am having multiple textboxes, i need to append the text for focused control