日期:2014-05-16  浏览次数:20434 次

如何横向滚动显示信息?
有一个div标签,代码如下所示:
HTML code

<div style="width:760px;height:72px;background-image:url('images/event_banner_normal.png');">
    <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
    <span id='event' style='height:72px;line-height:72px;font-size:25px;font-family:幼圆;font-weight:bold;' valign='middle'>
    </span>
    <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
</div>


想在id为event的span标签里显示一些信息,获取信息的代码如下:
JScript code

$.get("../api/hifapi.class.php?type=event","",function(data,textStatus){
    var obj=eval("("+data+")");
    for(var i=0;i<obj.length;i++)
    {
        $li=obj[i].title;
    }
});


其中obj[i].title就是第i条信息,想将所有信息都横向滚动显示在id为event的span标签里,该如何实现?

------解决方案--------------------
HTML code
var position=0,revol=9,speed=10;
function theforever_knight_go() {
    $('event').html(theforever_knight.substring(position, position + 160));
    if(position++ == theforever_knight.length) {
        if(revol-- < 2) return;
        position = 0;
    }
    id = setTimeout("theforever_knight_go()", 2000 / speed); 
}
var theforever_knight="";
$.get("../api/hifapi.class.php?type=event","",function(data,textStatus){
    var obj=eval("("+data+")");
    for(var i=0;i<obj.length;i++)
    {
        theforever_knight+=obj[i].title;
    }
    $('event').html(theforever_knight);
    theforever_knight_go();
});

------解决方案--------------------
div标签,代码如下所示:
HTML code

<div style="width:760px;height:72px;background-image:url('images/event_banner_normal.png');">
    <h1 class="event"></h1>
</div>