Note: I've updated the version of jQuery used. You can download a copy of it and host it yourself if you like (right click and 'save as'):
http://ajax.googleapis.com/ajax/libs.../jquery.min.js
This update is required.
There were also numerous changes, several to style, several to the markup, use of CDATA comment delimiters, etc. to make the page valid for its DOCTYPE and efficiency.
Looks just like the Twit version now, only a little better in IE:
Code:
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>News Ticker with jQuery</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
/* <![CDATA[ */
jQuery(function($){
var slideSpeed = 700;
var fadeInSpeed = 1000;
var fadeOutSpeed = 'normal';
var pause = 3500;
var start = true;
function newsticker(){
$('ul#listticker li').last().fadeOut(fadeOutSpeed, function(){
$('ul#listticker').prepend($(this).remove());
});
if(!start){
$('ul#listticker li').first().css({opacity: 0}).slideDown(slideSpeed, function(){
$(this).animate({opacity: 1}, fadeInSpeed, function(){
if(this.style.removeAttribute){
this.style.removeAttribute('filter');
}
});
});
}
start = false;
}
newsticker();
var interval = setInterval(newsticker, pause);
});
/* ]]> */
</script>
<style type="text/css">
body{
font-family:"Lucida Grande", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif;
font-size:12px;
}
#listticker{
height:200px;
width:400px;
overflow:hidden;
border:solid 1px #dedede;
padding:6px 10px 14px 10px;;
}
#listticker li{
border:0; margin:0; padding:0; list-style:none;
}
#listticker li{
height:60px;
padding:5px;
list-style:none;
}
#listticker a{
color:#000;
}
#listticker .news-title{
display:block;
font-weight:bold;
margin-bottom:4px;
font-size:11px;
}
#listticker .news-text{
display:block;
font-size:11px;
color:#666;
}
#listticker img{
float:left;
margin-right:14px;
padding:4px;
border:solid 1px #dedede;
}
</style>
</head>
<body>
<ul id="listticker">
<li>
<img src="1.png" alt="" />
<a href="" class="news-title">Health care reform</a>
<span class="news-text">President Obama has announced three bedrock requirements for real health care reform</span>
</li>
<li>
<img src="2.png" alt="" />
<a href="" class="news-title">National Geographic Animals</a>
<span class="news-text">Killer whales, Bengal tigers, crocs, more</span>
</li>
<li>
<img src="3.png" alt="" />
<a href="" class="news-title">Spotlight stars</a>
<span class="news-text">Marilyn Manson is not exactly a conformist. From his music — a meat-grinder...</span>
</li>
<li>
<img src="4.png" alt="" />
<a href="" class="news-title">Lost: the new serie is coming</a>
<span class="news-text">Watch full episodes online. The final season begins early 2010</span>
</li>
</ul>
</body>
</html>
Demo:
http://home.comcast.net/~jscheuer1/side/news_ticker/
Bookmarks