So suppose I have a JavaScript array containing a bunch of elements, but these elements don’t have anything in common (besides being members of the array). Is there any way to use jQuery to modify every element in this array at once? I’m currently making each element the member of a class, then using JQuery’s class selector, and then removing each element from the class. But I assume there has to be a better way. (I’m new to jQuery.)
for (key in myarray) {
myarray[key].className += " modifyme";
}
$(".modifyme").css("height", "100px");
for (key in myarray) {
myarray[key].className = myarray[key].className.replace(/\bmodifyme\b/,'');
}
Try this:
Or: