jQuery: find parent form and make all textfields inside the form editable

2012-03-03 von admin

This little jQuery script shows a solution for my next challenge.
It should be found, the parent form when the „bearbeiten“ button was pressed.
After that, all the fields inside the form must be editable.

 

Live Demo: Click
Download Demo: Demo_001.zip

$(document).ready(function () {
   $("input:text").attr('disabled', 'disabled');
});

$('input:button[name="bearbeiten"]').click(function() {
   setEditable(this);
});

function setEditable(_this) {

   $(_this).closest("form").find("input:text").each(function(index, elem ) {
      $(elem).removeAttr('disabled');
   });
}

thanks goes to: A.K. ;)