removing disabled attribute from fieldset
Hi, i have a bunch of fields in a field set which i want to disabled, if someone wants to edit the form they simply click the edit button and it unlocks the fields for them to edit. I am disabling the fields by adding the disabled attribute to the field set itself. I also need to remove the top margin from my form groups when the inputs are enabled. This is my jquery code so far which i can't get to work.
- <script>
- $(document).on('click' function (event) {
- event.preventDefault();
- var $btn = $(this);
- var $container = $(this).closest('.details-container');
- var $fieldset = $container.find('fieldset');
- $fieldset.removeAttr("disabled");
- $('.form-group.disabled').removeClass('disabled');
- });
- </script>
My original code looked liked like the below - but i wanted to make it cleaner rather than duplicating the code over again.
- $("#ContactAddressEdit").click(function(event){
- event.preventDefault();
- $('fieldset').removeAttr("disabled");
- $('.form-group.disabled').removeClass('disabled');
- });
- $("#ContactBillingEdit").click(function(event){
- event.preventDefault();
- $('fieldset').removeAttr("disabled");
- $('.form-group.disabled').removeClass('disabled');
- });
- $("#ContactPostagegEdit").click(function(event){
- event.preventDefault();
- $('fieldset').removeAttr("disabled");
- $('.form-group.disabled').removeClass('disabled');
- });
A fiddle can be found here