Please login or register. Welcome to the Studio, guest!


Quick Links:


newBookmarkLockedFalling

Aaron

Aaron Avatar
Bad Wolf

****
Dedicated Studio Member

859


November 2006
Description: Returns an array of a specified element based on it's attributes.

Syntax: searchElem(string, {parameters})

function searchElem(a, b) {
var n = [];
outer:
for(var i = document.getElementsByTagName(a), x = 0; x < i.length; x ++) {
for(var e in b)
if((b[e].constructor == RegExp ? !i[x][e].match(b[e]) : i[x][e] != b[e]))
continue outer;
n.push(i[x]);
}
return n;
}


Example: searchElem("td", { width: "1%", className: "windowbg" })




Last Edit: Apr 20, 2007 19:31:38 GMT by Aaron

Chris

Chris Avatar

******
Head Coder

19,519


June 2005
You should allow for RegExp's by checking the constructor. ;)

Aaron

Aaron Avatar
Bad Wolf

****
Dedicated Studio Member

859


November 2006
Yeah, added


Last Edit: Apr 20, 2007 19:32:11 GMT by Aaron

Mancer

Mancer Avatar

**
Official Member

95


April 2007
very nice. i was just thinking about a function that could do something similar to this the other day. glad you beat me to it :D
I'm starting this revolution: This is my sandbox, y'all just dig'n.

Chris

Chris Avatar

******
Head Coder

19,519


June 2005
Now I'm content. :P Good job.

newBookmarkLockedFalling