Reputation: 1037
I have a variable in Javascript:
var test ="whatever"
I just want to pass this variable inside a hidden input:
<input type="hidden" class="myinput" value="">
I tried:
$('.myinput').attr('test');
But it does not seem to work.
Thank you for your help.
Upvotes: 0
Views: 7003
Reputation: 79830
.val
function to set the value of hidden input.See below code:
$('.myinput').val(test);
Upvotes: 8