jQuery toggle() setInterval not working
I have this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<link href="http://fonts.googleapis.com/css?family=Geo:regular" rel="stylesheet" type="text/css" >
<style>
body {
font-family: 'Geo', serif;
font-size: 32px;
font-style: normal;
font-weight: 400;
text-shadow: none;
text-decoration: none;
text-transform: none;
letter-spacing: 0em;
word-spacing: 0em;
line-height: 1.2;
}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"></script>
<script type="text/javascript">
function cursorAnimation()
{
$(".cursor").toggle();
}
$(document).ready(function()
{
setInterval ( "cursorAnimation()", 1900);
});
</script>
<title>Untitled 2</title>
</head>
<body>
So, what's the deal?<span class="cursor">[WARNING]</span>
</body>
</html>
and it works -- technically. However, the toggle is working but it's going WAY too fast. I tried messing with setInterval but it's not doing a dang thing... I just want 开发者_运维百科for it to appear and disappear on loop (like a cursor) but without the fading.
Try setInterval( cursorAnimation, 1900 );
it works as a fiddle just fine, so I wonder what is happening?
i changed it to a fadeToggle() to make it not as 'hard'
setInterval(function cursorAnimation() {
$('.cursor').fadeToggle(); }, 1900);
http://jsfiddle.net/r6C3w/
精彩评论