有一个div标签,代码如下所示:<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标签里显示一些信息,获取信息的代码如下:$.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标签里,该如何实现?

解决方案 »

  1.   

    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();
    });
      

  2.   

    div标签,代码如下所示:<div style="width:760px;height:72px;background-image:url('images/event_banner_normal.png');">
        <h1 class="event"></h1>
    </div>获取信息的代码如下: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="";
    $(document).ready(function() {
    $.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();
        });
    });