Skip to content

Instantly share code, notes, and snippets.

@imaz
Created July 20, 2011 02:03
Show Gist options
  • Save imaz/1094181 to your computer and use it in GitHub Desktop.
Save imaz/1094181 to your computer and use it in GitHub Desktop.
js fade in/out
<html>
<head>
<title>js study fade</title>
<script language="JavaScript">
<!--
itv = 50;
cnt = 0;
function strFade(str){
c = str.charAt(cnt++);
document.getElementById("ID").style.color="#"+c+c+c+c+c+c;
if(cnt < str.length) setTimeout("strFade('"+str+"')",itv);
if(cnt str.length) cnt=0;
}
-->
</script>
</head>
<body>
<span id="ID">(´▽`)</span>
<br><br>
<input type="button" value="fade in" onClick="strFade('fedcba9876543210')">
<input type="button" value="fade out" onClick="strFade('0123456789abcdef')">
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment