Hi All,
Appreciate help in resolving the below issues.....
With every refresh I wanted to change the text color in marquee tag by calling javascript function......
I am getting color code like #18EEC5 ......but when calling script function from marquee tag nothing is happening......
<html>
<head>
<script type="text/javascript">
function getRandomColor() {
var letters = '0123456789ABCDEF';
var color = '#';
for (i = 0; i < 6; i++ ) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}
</script>
</head>
<body>
<script>
$col=getRandomColor();
document.write(getRandomColor());
</script>
<marquee style="color: 'document.write(getRandomColor())'; font-size: 20pt; font-weight: bold">
Text Color Changes
</marquee>
</body>
</html>
Thanks,
Nick
Need help....Changing text color in every refresh
Moderators: egami, macek, gesf
-
- php-forum Super User
- Posts: 197
- Joined: Wed Jun 15, 2016 8:35 am
Try this :
Code: Select all
<html>
<head>
<script>
function getRandomColor() {
var letters = '0123456789ABCDEF';
var color = '#';
for (i = 0; i < 6; i++ ) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}
</script>
<style>
#marquee {
font-size: 20pt;
font-weight: bold;
}
</style>
</head>
<body>
<marquee id="marquee">Text Color Changes</marquee>
<script>
$marquee = document.getElementById('marquee');
$marquee.style.color = getRandomColor();
</script>
</body>
</html>
-
- New php-forum User
- Posts: 13
- Joined: Thu Feb 05, 2015 12:21 pm
Hi,
Thanks for your help.
Issue got resolved....
Thanks,
Nick
Thanks for your help.
Issue got resolved....
Thanks,
Nick