I'm struggling to create a loop that will smoothly transition the border color of an image from black to yellow and back again over a set number of seconds. Additionally, I want the loop to stop when the image is clicked on. I feel like I might not be using the correct tools for this task and could use some guidance on how to approach it. Any suggestions would be greatly appreciated!
Here is what I have attempted so far, but if there is a more efficient method, please let me know!
for (i = 100; i >= 0; i--) {
$("#imgid").css("border-color", 'rgb(' + i + '%,' + i + '%,0)');
}
There are a few specific things I'd like to learn about:
1.) I am unsure how to merge two loops in order to move both upwards and downwards, allowing the border color to transition between black and yellow continuously. Is this achievable with just one loop?
2.) How can I slow down the loop to control the speed at which the border color fades?
3.) What is the best way to terminate the loop using an onclick() event?