getElementsByClassName

qualora non si avesse a disposizione jquery o simili , semplice funzione javascript per recuperare gli oggetti che presentano
la stessa classe

function getElementsByClass(node,searchClass,tag) {
var classElements = new Array();
var els = node.getElementsByTagName(tag); // use "*" for all elements
var elsLen = els.length;
var pattern = new RegExp("\b"+searchClass+"\b");
for (i = 0, j = 0; i < elsLen; i++) {
if ( pattern.test(els[i].className) ) {
classElements[j] = els[i];
j++;
}
}
return classElements;
}

posted @ lunedì 4 maggio 2009 16:39

Print

Comments on this entry:

# Moncler Doudoune

Left by Moncler Doudoune at 13/12/2012 06:39
Gravatar
la série animée Bingjie campus Bas montrer dynamique. Les couleurs vives et audacieuses. Complété avec cordon d

# re: getElementsByClassName

Left by he at 13/11/2014 18:58
Gravatar
innovation provides apps check credit score major months ebbs and flows credit report score perspective adaptability 2

# HarietDental

Left by HarietDental at 24/02/2016 12:29
Gravatar
thanks for your post
Comments have been closed on this topic.
«novembre»
domlunmarmergiovensab
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567