The documentation on http://prototypejs.org/api/element/writeAttribute is a wee bit scarce. So here’s a quick one on usage.
To add an attribute:
$('foo').writeAttribute('title', 'bar');
To remove an attribute:
$('foo').writeAttribute('title', null);
To enable all disabled form elements (in a form with the id ‘container’):
$('container').select('[disabled="disabled"]').each(function(e) { $(e).writeAttribute('disabled', null); });
Thank you so much! For the life of me, I cannot understand why the documentation at the official Prototype website is so poor. Their explanation about practically everything (not just writeAttribute) seems so short and cryptic. It’s almost like they’re trying their best to hide what Prototype can do. Weird!
It’s such a pity because from my limited experience coding with Prototype so far, it seems like a great framework.
I’m glad that this has been of use.
It annoyed me 3 years ago.
Since then, I’ve found jQuery to be a much more usable framework.
Happy coding 🙂