/    Sign up×
Community /Pin to ProfileBookmark

Make Text Flash on and Off w/ JavaScript

I am trying to make some text on my page flash, i.e. the text is there, and after one second it disappears, and then comes back, etc….

I know, I can just use images, maybe make an animated GIF or something, but I was trying to use text to reduce the size and lower the required bandwidth. Is this possible? ?

Thanks.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@DokJul 16.2007 — This will blink the text from read to white every second
[code=html]<html>
<head>
<script type="text/javascript">
function init() {
window.setInterval(blink,1000);
}

function blink() {
var elm = document.getElementById('blinkDiv');
if (elm.style.color == "#ff0000")
elm.style.color = "#ffffff";
else
elm.style.color = "#ff0000";
}
</script>
</head>
<body onload="init();" style="background-color: #ffffff;">
<div id="blinkDiv" style="color: #ff0000;">some text</div>
</body>
</html>[/code]
Copy linkTweet thisAlerts:
@blakeeliasauthorJul 16.2007 — Thank you very much, Dok. This works fine and is exactly what I needed.
×

Success!

Help @blakeelias spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...