I use some JavaScript to change the color of some div’s inside my HTML and have two problems with them.
The first one is that I have a CSS triangle and I need to change the border color on click event but wont work with the next code:
document.getElementById('triangle').style.borderLeft = color;
Anyone any idea?
The next problem is the next: once the color has been changed, I’d like to save it as a cookie and load it when the visitor visits the next time.
This is my current JavaScript:
function change(color)
{
document.getElementById('tinybox1').style.backgroundColor = color;
document.getElementById('tinybox2').style.backgroundColor = color;
document.getElementById('tinybox3').style.backgroundColor = color;
document.getElementById('tinybox4').style.backgroundColor = color;
document.getElementById('text').style.backgroundColor = color;
document.getElementById('pinnable').style.backgroundColor = color;
// document.getElementById('triangle').style.borderLeft = color;
}
I hope someone can help me out!
To change just the border colour without having to also specify size and type, use: