开发者

How to make Quick news bar reading char by char

I see in almost news websites bar called quick news and its appe开发者_Python百科ar and reading character by character like this site http://www.filgoal.com/English/DefaultDynamic.aspx in the latest news section under menus. i hope if any one can help me to know how it works or give me a sample for that. thanks,


There is a good jQuery plugin that does exactly this. You can read the documentation and download it from

http://plugins.jquery.com/project/BBCnewsTicker

There is an example of it in action on this page

http://www.makemineatriple.com/jquery?newsTicker=


The BBC style news ticker plugin for jQuery will do what you want.


Well, something like this would do if you don't want to use any plugins:

<html>
<head>
<script>
function printTextDelayed(item, text, symbolNum) {
    if (symbolNum == undefined) symbolNum = 0;
    if (symbolNum < text.length-1) {
        item.innerHTML = text.substring(0,symbolNum+1)+"_";
        setTimeout(function() {
            printTextDelayed(item, text, symbolNum+1);
        }, 100+Math.random()*300);
    } else {
        item.innerHTML = text;
    }
}

function printButtonClick() {
    printTextDelayed(document.getElementById("dynalink"), document.getElementById("dynatext").value);
}
</script>
</head>
<body>
    <input type="text" id="dynatext">
    <input type="button" value="Print" onclick="printButtonClick();"/>
    <br/>
    <a href="#somelink" id="dynalink"></a>
</body>
</html>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜