How to Set the Value of a Hidden Input with jQuery

Get the value of the value attribute of a hidden input field: using Input Hidden value Property. hiddenObject.value

jQuery Code: Set hidden field value

Example

$("#yourFormHVal").val("tamilNameHere");

jquery set value of hidden input field code example

Example 1: get value of hidden field jquery

var Lt = $('#love_template').val();

Example 2: jquery set hidden field value

$("#new_cart").val("pakainfo_v1");

Set value of hidden input with jquery

index.html

<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.0.js"></script>
<script type="text/javascript">
$(window).load(function(){
var cnt_dt = $("input[name=product_id]:hidden");
cnt_dt.val('Good Luck!');
console.log('The value of hidden input is: ' + cnt_dt.val())
});

</script>
</head>
<body>
<input name="product_id" type="hidden">
</body>
</html>

I hope you get an idea about jquery set value of hidden input.


#jquery 

How to Set the Value of a Hidden Input with jQuery
1.10 GEEK