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.
.val
function to set the value of hidden input. See below code:
$('.myinput').val(test);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.