Search code examples
jqueryhidden-field

Setting hidden field value with Jquery $('#id').attr("value", 'val'); not working in IE


I noticed that IE doesnt fill the value of a hidden field, using the code below, while Chrome and FF have no problem with this.

$('#id').attr("value", 'val');

I tried a few other things like .setAttribute or .val() = "val";


Solution

  • You need to pass value to val() jquery function,

    $('#id').val("your value");