Javascript 如何在我的站点上使用jquery?

Javascript 如何在我的站点上使用jquery?,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我不会将所有示例代码复制到这里。 但这是jquery演示页面: <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script> <script src="http://risq.github.io/jquery-advanced-news-ticker/assets/js/jquery.newsTicker.js"></script> <script> va

我不会将所有示例代码复制到这里。 但这是jquery演示页面:

<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="http://risq.github.io/jquery-advanced-news-ticker/assets/js/jquery.newsTicker.js"></script>
<script>
    var count = 300;
    var counter = setInterval(timer, 1000); //1000 will  run it every 1 second

    function timer() {
    count = count - 1;
    if (count == -1) {
            clearInterval(counter);
            return;
    }

    var seconds = count % 60;
    var minutes = Math.floor(count / 60);
    var hours = Math.floor(minutes / 60);
    minutes %= 60;
    hours %= 60;
    document.getElementById("timer").innerHTML = hours + " Hours " + minutes + " Minutes and " + seconds + " Seconds left untill the next news update."; // watch for spelling
    }
    function news(){
   $('body').find('.newsticker').remove();//It will clear old data if its present 
   var file = "http://newsxpressmedia.com/files/theme/test.txt";
    $.get(file, function (txt) {
            //var lines = txt.responseText.split("\n");
            var lines = txt.split("\n");
            $ul = $('<ul class="newsticker" />');
            for (var i = 0, len = lines.length; i < len; i++) {
                //save(lines[i]); // not sure what this does
                $ul.append('<li>' + lines[i] + '</li>'); //here 
            }
            //$ul.appendTo('body').newsTicker({
            $ul.appendTo('div.wcustomhtml').newsTicker({
                row_height: 48,
                max_rows: 2,
                speed: 6000,
                direction: 'up',
                duration: 1000,
                autostart: 1,
                pauseOnHover: 1
            });
    });
    }
    $(function() {
    news();
    setInterval(function(){
      news();
    },30000)  // it will call every 1 min you can change it
    });
</script>
<br><br><span id="timer"></span><br><br>

我想在我的网站上添加一个例子,里面有红色的最新新闻和滚动文本。 在演示页面中有示例源代码的链接

在我的网站上,我现在有了这段代码,可以从文本文件中逐行读取文本,并向上滚动文本,在文本上方有一个计时器倒计时,直到下一次更新

我想以某种方式使文本文件中的文本逐行阅读,并将其添加到演示页面中的最新新闻示例中,以便它在我的网站上与演示页面中的视觉效果和方式相同

这是我正在工作的代码,但现在我希望我阅读的每一行的文本文件都能显示在最新的新闻中,如演示页面中:

<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="http://risq.github.io/jquery-advanced-news-ticker/assets/js/jquery.newsTicker.js"></script>
<script>
    var count = 300;
    var counter = setInterval(timer, 1000); //1000 will  run it every 1 second

    function timer() {
    count = count - 1;
    if (count == -1) {
            clearInterval(counter);
            return;
    }

    var seconds = count % 60;
    var minutes = Math.floor(count / 60);
    var hours = Math.floor(minutes / 60);
    minutes %= 60;
    hours %= 60;
    document.getElementById("timer").innerHTML = hours + " Hours " + minutes + " Minutes and " + seconds + " Seconds left untill the next news update."; // watch for spelling
    }
    function news(){
   $('body').find('.newsticker').remove();//It will clear old data if its present 
   var file = "http://newsxpressmedia.com/files/theme/test.txt";
    $.get(file, function (txt) {
            //var lines = txt.responseText.split("\n");
            var lines = txt.split("\n");
            $ul = $('<ul class="newsticker" />');
            for (var i = 0, len = lines.length; i < len; i++) {
                //save(lines[i]); // not sure what this does
                $ul.append('<li>' + lines[i] + '</li>'); //here 
            }
            //$ul.appendTo('body').newsTicker({
            $ul.appendTo('div.wcustomhtml').newsTicker({
                row_height: 48,
                max_rows: 2,
                speed: 6000,
                direction: 'up',
                duration: 1000,
                autostart: 1,
                pauseOnHover: 1
            });
    });
    }
    $(function() {
    news();
    setInterval(function(){
      news();
    },30000)  // it will call every 1 min you can change it
    });
</script>
<br><br><span id="timer"></span><br><br>

var计数=300;
var计数器=设置间隔(计时器,1000)//1000将每1秒运行一次
函数计时器(){
计数=计数-1;
如果(计数==-1){
清除间隔(计数器);
回来
}
var秒数=计数%60;
var分钟=数学地板(计数/60);
var小时=数学楼层(分钟/60);
分钟%=60;
小时%=60;
document.getElementById(“timer”).innerHTML=hours+“hours”+minutes+“minutes”和“+seconds+”秒,直到下一次新闻更新为止。”;//注意拼写
}
功能新闻(){
$('body').find('.newsticker').remove();//如果旧数据存在,它将清除旧数据
变量文件=”http://newsxpressmedia.com/files/theme/test.txt";
$.get(文件、函数(txt){
//var lines=txt.responseText.split(“\n”);
变量行=txt.split(“\n”);
$ul=$('
    ); 对于(变量i=0,len=lines.length;i”+行[i]+“”);//此处 } //$ul.appendTo('body')。新闻票证({ $ul.appendTo('div.wcustomhtml')。新闻代码({ 行高:48, 最大行数:2, 速度:6000, 方向:'向上', 持续时间:1000, 自动启动:1, 暂停悬停:1 }); }); } $(函数(){ 新闻(); setInterval(函数(){ 新闻(); },30000)//它将每1分钟调用一次您可以更改它 });



我需要下载演示示例文件吗?或者我可以像在代码中那样使用链接吗?

运行插件需要什么? 您需要知道的是(:

您需要什么:

  • jquery1.7+
  • jquery.easy-ticker脚本
  • 了解语法
  • 使用jQuery运行
语法 - 哪里

//您应该在此处添加脚本和样式
//你应该在这里添加所有网站结构
//现在在这里运行脚本
例如:

关于链接 Jquery:

您可以从谷歌获取:

或下载并在您的网站上托管:

_

其他js的

您可以在Google Drive上托管:

也许你可以在这里找到:www.cdnjs.com

或者下载并在您的网站上托管

运行插件需要什么? 您需要知道的是(:

您需要什么:

  • jquery1.7+
  • jquery.easy-ticker脚本
  • 了解语法
  • 使用jQuery运行
语法 - 哪里

//您应该在此处添加脚本和样式
//你应该在这里添加所有网站结构
//现在在这里运行脚本
例如:

关于链接 Jquery:

您可以从谷歌获取:

或下载并在您的网站上托管:

_

其他js的

您可以在Google Drive上托管:

也许你可以在这里找到:www.cdnjs.com

或者下载并在您的网站上托管

$('.myWrapper').easyTicker({
    // list of properties
});
<!DOCTYPE html>
<html>
<head>
// you should add scripts and styles here
</head>
<body>
// you should add all website structure here

// now run scripts here
</body>
</html>