Skip to content

Instantly share code, notes, and snippets.

@xirukitepe
Created March 2, 2013 09:13
Show Gist options
  • Save xirukitepe/5070257 to your computer and use it in GitHub Desktop.
Save xirukitepe/5070257 to your computer and use it in GitHub Desktop.
setAttribute
$("#add-item").click(function() {
var divs = document.getElementsByClassName('budget-field');
var divs2 = document.getElementsByClassName('mini-field');
var divs3 = document.getElementsByClassName('text-area');
var divs4 = document.getElementsByClassName('check-box');
var divs5 = document.getElementsByTagName('select');
for (i = 0; i < divs.length; i++) {
divs[i].setAttribute('readonly',true);
}
for (i = 0; i < divs2.length; i++) {
divs2[i].setAttribute('readonly',true);
}
for (i = 0; i < divs3.length; i++) {
divs3[i].setAttribute('disabled', true);
}
for (i = 0; i < divs4.length; i++) {
divs4[i].disabled = true;
}
for (i = 0; i < divs5.length; i++) {
divs5[i].setAttribute('disabled', true);
}
});
$("#update").click(function() {
var x = document.getElementsByClassName('budget-field');
for (i = 0; i < x.length; i++) {
x[i].setAttribute('readonly','false');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment