Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  5] [ 2]  / answers: 1 / hits: 9965  / 11 Years ago, mon, december 16, 2013, 12:00:00

Let me show you a piece of my code so you know what I'm struggling with.



<input type=text id=input />


This is the input element I am talking about. What I want to do is put the value of :



<input type=button id=b1 value=1 />


in the textbox everytime the button is clicked.



A side question I can't google because it's part of searching syntax.



What is the difference between and '' (with something in-between) and when do you use one of them?



EDIT: Right now the click event is adding the value of the button to the textbox. But not to the text inside the textbox! IT just literally adds it, as if the textbox is a division or something.



The jquery/javascript code



$(#b1).click(toev);

function toev(){
$(#input).text($(append($(this).val())));
};

More From » jquery

 Answers
13

Do you want something like this :DEMO



$('#b1').click(
function(){
$('#input').val($('#input').val()+$(this).val());
}
);

[#49492] Sunday, December 15, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
emerald

Total Points: 547
Total Questions: 96
Total Answers: 122

Location: Oman
Member since Fri, Dec 23, 2022
1 Year ago
;