Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
154
rated 0 times [  155] [ 1]  / answers: 1 / hits: 16293  / 14 Years ago, wed, march 16, 2011, 12:00:00

If i have an input like so:



<input type=text id=textvalue />


the following code will change its value:



$(document).ready(function() {
$('#textvalue').val(hello);
});


however the following will not work:



$(document).ready(function() {
var = hello;
$('#textvalue').val(var);
});


Why does the second one not work? I need to be able to change the value of the textbox to the value of a variable


More From » jquery

 Answers
50

Your var statement needs to look something like this



var something = hello

$('#textvalue').val(something );


Right now your not actually assigning a value to a variable, and then you are trying to use the var keyword.



Variable Reference


[#93250] Tuesday, March 15, 2011, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
wilson

Total Points: 27
Total Questions: 93
Total Answers: 93

Location: Tajikistan
Member since Sun, Aug 29, 2021
3 Years ago
;