function get_random_color() {
var letters = '0123456789ABCDEF'.split('');
var color = '#';
for (var i = 0; i < 6; i++ ) {
color += letters[Math.round(Math.random() * 15)];
}
return color;
}
function textNodesUnder(root){
var n, a=[], walk=document.createTreeWalker(root,NodeFilter.SHOW_TEXT,null,false);
while(n=walk.nextNode())
{
n.parentNode.setAttribute("style","color:"+get_random_color());
}
}
textNodesUnder(document.body)
run the code on firebug to see the effect or put the code bellow all your html within a script tag
No comments:
Post a Comment