[英]How do i use the jquery on my site?
我不會將所有示例代碼復制到此處。 但這是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>
我需要下載演示示例文件嗎? 或者我可以像在代碼中那樣使用鏈接?
您只需要在項目的GitHub (:
您需要什么:
<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>
$('.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>
示例: http : //pastebin.com/S3LBtSue
jQuery:
您可以從Google獲取: https : //developers.google.com/speed/libraries/devguide?hl=pt-br#jquery
或下載並托管在您的網站上: http : //jquery.com/download/
_
其他js的
您可以在Google雲端硬盤上托管: http : //www.komku.org/2013/08/how-to-host-javascript-or-css-files-on-google-drive.html
也許您可以在這里找到:www.cdnjs.com
或下載並托管在您的網站上
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.