PDA

View Full Version : how can you change css class on a group of elements?



gmoney
21 Feb 2007, 3:52 PM
I want to replace this:



for(i=0; i<document.forms[3].elements.length; i++){
document.forms[3].elements[i].className = '';
}



with the Ext equivalent.

I tried Ext.select together with a removeClass call... but I am not sure if that is what I need to do and I couldnt get it to work unless I use the ugly code above.

tryanDLS
21 Feb 2007, 6:11 PM
First you need to give your form a unique id. Then something like this.


var els = getEl(formId).select('input'); // get all the INPUT elements within the form
or
var els = getEl(formId).select('.xyz') // get all the elements with class=xyz within the form

now invoke the fn on each item
els.each(function(o) {o.removeClass('xyz');}));