lowmatild
AI Systems Architect
2
MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1
300 XP
In this article, we are going to learn about Color Effect in Text using JavaScript. You can use this to your future projects or websites to attract the user. This is very simple kind of source code, you can easily change the base color, text color, and the flash speed in the text.
In our example, we have white color for the base, yellow color for the text, and 80 milliseconds for the flash speed.
This is the script source code that you can edit the color and the speed.
Complete Script Source Code
Kindly copy and paste this simple script source code to your BODY tag of your page. To have a great neon effect in your text.
Output
This is the output after constructing the script in your editor.
Kindly click the "Download Code" button below for full source code. Thank very much. Enjoy coding.
Share us your thoughts and comments below. Thank you so much for dropping by and reading this tutorial post. For more updates, don’t hesitate and feel free to visit this website more often and please share this with your friends or email me at [email protected]. Practice Coding. Thank you very much.
Download
In our example, we have white color for the base, yellow color for the text, and 80 milliseconds for the flash speed.
This is the script source code that you can edit the color and the speed.
- <
script language=
"JavaScript1.2"
>
- var
message =
"Welcome to Sourcecodester! Free source code."
- var
neonbasecolor =
"white"
- var
neontextcolor =
"yellow"
- var
flashspeed =
80
//in milliseconds
- </
script>
Complete Script Source Code
Kindly copy and paste this simple script source code to your BODY tag of your page. To have a great neon effect in your text.
- <
script language=
"JavaScript1.2"
>
- var
message =
"Welcome to Sourcecodester! Free source code."
- var
neonbasecolor =
"white"
- var
neontextcolor =
"yellow"
- var
flashspeed =
80
//in milliseconds
- ///No need to edit below this line/////
- var
n=
0
- if
(
document.all
||
document.getElementById
)
{
- document.write
(
''
)
- for
(
m=
0
;
m<
message.length
;
m++
)
- document.write
(
'<span id="neonlight'
+
m+
'">'
+
message.charAt
(
m)
+
'</span>'
)
- document.write
(
''
)
- }
- else
- document.write
(
message)
- function
crossref(
number)
{
- var
crossobj=
document.all
?
eval(
"document.all.neonlight"
+
number)
:
document.getElementById
(
"neonlight"
+
number)
- return
crossobj
- }
- function
neon(
)
{
- //Change all letters to base color
- if
(
n==
0
)
{
- for
(
m=
0
;
m<
message.length
;
m++
)
- //eval("document.all.neonlight"+m).style.color=neonbasecolor
- crossref(
m)
.style
.color
=
neonbasecolor
- }
- //cycle through and change individual letters to neon color
- crossref(
n)
.style
.color
=
neontextcolor
- if
(
n<
message.length
-
1
)
- n++
- else
{
- n=
0
- clearInterval(
flashing)
- setTimeout(
"beginneon()"
,
1500
)
- return
- }
- }
- function
beginneon(
)
{
- if
(
document.all
||
document.getElementById
)
- flashing=
setInterval(
"neon()"
,
flashspeed)
- }
- beginneon(
)
- </
script>
Output
This is the output after constructing the script in your editor.

Kindly click the "Download Code" button below for full source code. Thank very much. Enjoy coding.
Share us your thoughts and comments below. Thank you so much for dropping by and reading this tutorial post. For more updates, don’t hesitate and feel free to visit this website more often and please share this with your friends or email me at [email protected]. Practice Coding. Thank you very much.
Download
You must upgrade your account or reply in the thread to view hidden text.