I need to add a hidden form element (as part of a large form) which needs to be created and added dynamically. A snippet of what I have so far is:
var value = '*****';
var inputHidden = $('<input>').attr('type', 'hidden')).addClass("warningOnly").val(value);
// conditionally disable new element here
$(elem).append(inputHidden);
This works as expected. What I also want to do is conditionally disable the hidden input before adding it to the form. What I have tried are variants of:
$(inputHidden).prop('disabled', true);
This does not disable the element and I need a way of doing this.
.attr('type',hidden))-- you double-close the end parenthesis. Shouldn't matter, but its a thing.