Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How I can change the border color of the textarea frequently by javascript ?
Posted
Comments
Mathi Mani 30-May-15 3:48am    
What do you mean by frequently?
Sergey Alexandrovich Kryukov 30-May-15 5:49am    
What have you tried so far?
—SA

1 solution

You can use setInterval() to change the border color every N milliseconds. Store all colors you want in an array, and always pick the next element when changing the color, and go back to the first element when there are no elements left.
JavaScript
var milliseconds = 2000; // 2 seconds
var colors = ["red", "green", "blue"]; // add more if you want
var currentIndex = 0;
setInterval(function () {
    var newColor = colors[currentIndex];
    document.getElementById("yourArea").style.borderColor = newColor;
    currentIndex++;
    if (currentIndex >= colors.length) {
        currentIndex = 0;
    }
}, milliseconds);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900