How can i append an input value in jquery | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

How can i append an input value in jquery

i have an input tag with a value of 0 and also a button with id 1...is there anyway i can click the button to append the value of the input tag, have done this with a p tag, its working fine, here is my code for that of input tag. $("#one").click(function() { $("input :value").append(1); });

5th Dec 2018, 6:25 AM
Asaølu Elïjah
Asaølu Elïjah - avatar
5 Answers
+ 7
// You can make 1 in string but in number, // I'm not sure if he have a error in the code.
5th Dec 2018, 7:02 AM
program
program - avatar
+ 2
$("#one").click(function(){ $(this).val(1); });
5th Dec 2018, 7:57 AM
bondcoder
bondcoder - avatar
+ 2
I think this works $("#one").click(function() { $("input").attr("value").append(1); });
5th Dec 2018, 10:05 AM
Harshini Srinivas
Harshini Srinivas - avatar
+ 1
its not working also for string bro
5th Dec 2018, 7:15 AM
Asaølu Elïjah
Asaølu Elïjah - avatar
+ 1
thanks all...i decided not to use input again, am now using span tag. and its working fine
5th Dec 2018, 12:53 PM
Asaølu Elïjah
Asaølu Elïjah - avatar