Coloring Css Shapes With Different Colors
I'm looking for a solution to color some css shapes (don't really want to use svg as in this example: http://bl.ocks.org/widged/4545199 , but the output would be pretty similar). W
Solution 1:
I don't know what is exactly your question, but I think that you are asking about to get the current color to pass through PHP, huh?
functiongetCurrentColor() {
var color = document.getElementById("box").style.backgroundColor;
// you can now use AJAX or a form to pass this value to php
EDIT
OP was explained better in comment. You can:
// add style to 3 boxesfunctionbutton_click() {
index = (index + 1) % colors.length;
document.getElementById("box").style.backgroundColor = colors[index];
document.getElementById("asd").style.backgroundColor = colors[index];
document.getElementById("fgh").style.backgroundColor = colors[index];
}
// returns the current color of #boxfunctiongetColor() {
returndocument.getElementById("box").style.backgroundColor;
}
functionwhichIsColor(color) {
// select all elementsvar els = document.getElementsByTagName("div");
//iterate through themfor(var i in els) {
// if matches the color passed in argument:if(els[i].style.backgroundColor === color) {
return els[i];
}
}
}
Good luck!
Post a Comment for "Coloring Css Shapes With Different Colors"