|
Post by Schubaltz on Jun 11, 2007 11:23:10 GMT -5
Description: Simple snippet that allows you to run a function on elements with certain properties.
**Requires correlate function.**
Syntax: forElements(in Node, {,properties}, function)
function forElements(a, b, c) { for(var i = a.getElementsByTagName(b.tagName || (b.nodeName || "*")), x = 0; x < i.length; x ++) { if(!correlate(i[x], b)) continue; c(i[x]); } }
Example:
<html> <head></head> <body> <div class="wrap" style="font-size: 10px">Paragraph 1</div> <div class="wrap" style="font-size: 10px">Paragraph 2</div> <div class="wrap" style="font-size: 10px">Paragraph 3</div> <script type="text/javascript"> <!-- forElements(document.body, { className: "wrap", style: { fontSize: "10px" }, firstChild: { data: /1|3/ } }, function(a) { a.style.color = "#009933"; }); //--> </script> </body> </html>
|
|