Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set value of hidden input with jquery

People also ask

How do you assign a value to a hidden input?

In jQuery to set a hidden field value, we use . val() method. The jQuery . val() method is used to get or set the values of form elements such as input, select, textarea.

How can remove hidden field value in jQuery?

in jquery: $('#hiddenfieldid'). val(''); $('#Projectid').


You should use val instead of value.

<script type="text/javascript" language="javascript">
$(document).ready(function () { 
    $('input[name="testing"]').val('Work!');
});
</script>

This worked for me:

$('input[name="sort_order"]').attr('value','XXX');

$('input[name="testing"]').val(theValue);

Suppose you have a hidden input with id XXX, if you want to assign a value to the following

<script type="text/javascript">

    $(document).ready(function(){
    $('#XXX').val('any value');
    })
</script>