Q: How do I color every second character of a string into red in javascript? for example: var a="This is a string". I want the first, the third character and so on to be colored in red.
A: Split the string into an array holding each character in the string. Loop over that array and use condition logic to see if the array index position is divisible by any number you wish. If it is then you alter the target element to your liking. Watch the video for code explanation.
Смотрите видео Q+A - How to alternate text color using JavaScript онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Adam Khoury 19 Ноябрь 2013, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 24,634 раз и оно понравилось 192 людям.