gpt4 book ai didi

javascript - 我如何在我的网站上使用 jquery?

转载 作者:行者123 更新时间:2023-11-30 10:16:40 24 4
gpt4 key购买 nike

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

Demo Page

我想在我的站点中添加带有红色最新消息和内部滚动文本的示例。在演示页面中有示例源的链接。

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

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

这是我的代码,但现在我希望我阅读的每一行文本文件都显示在最新消息中,就像在演示页面中一样:

<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>

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

最佳答案

运行插件需要什么?

所有你需要知道的都在 project's GitHub 上(:

您需要:

  • Jquery 1.7+
  • jquery.easy-ticker 脚本
  • 了解语法
  • 使用 jQuery 运行

语法

<div class="myWrapper">
<ul>
<li>List element 1</li>
<li>List element 2</li>
<li>List element 3</li>
<li>List element 4</li>
</ul>
</div>

or

<div class="myWrapper">
<div>
<div>Element 1</div>
<div>Element 2</div>
<div>Element 3</div>
<div>Element 4</div>
</div>
</div>

使用 jQuery 运行

$('.myWrapper').easyTicker({
// list of properties
});

- JSFiddle

在哪里?

<!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>

示例:http://pastebin.com/S3LBtSue

关于链接

Jquery:

你可以从谷歌获取:https://developers.google.com/speed/libraries/devguide?hl=pt-br#jquery

或下载并托管在您的网站上:http://jquery.com/download/

_

其他js的

您可以在 Google Drive 上托管:http://www.komku.org/2013/08/how-to-host-javascript-or-css-files-on-google-drive.html

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

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

关于javascript - 我如何在我的网站上使用 jquery?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23329241/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com