Slider PHP, MYSQL and JS
Slider PHP, MYSQL and JS
我在一个文章网站上工作,这些文章是在一个数据库上,它可以删除/添加(CMS),这一切都是完美的工作,数据库和滑块。现在我要做的是对滑动条上的文章进行积分。这是我的代码,它不工作,有什么建议吗?由于
JS:
sliderInt=1;
sliderNext=2;
$("#newsText > p#1").fadeIn(500);
startSlider();
function startSlider() {
count = $("#newsText > p").size();
loop = setInterval (function() {
if (sliderNext>count) {
sliderNext = 1;
sliderInt = 1;
}
$("#newsText > p").fadeOut(500);
$("#newsText > p#" + sliderNext).delay(500).fadeIn(500);
sliderInt = sliderNext;
sliderNext ++;
} ,7500);
}
function stopLoop() {
window.clearInterval(loop);
}
function showSlide(id) {
stopLoop();
if (id>count) {
id = 1;
}
else if (id<1) {
id=count;
}
$("#newsText > p").fadeOut(500);
$("#newsText > p#" + id).fadeIn(500);
sliderInt = id;
sliderNext = id + 1;
startSlider();
}
})
PHP/HTML: <?php
include_once('php/CMS/includes/connection.php');
include_once('php/CMS/includes/article.php');
$article = new Article;
$articles = $article->fetch_all();
?>
//.......BODY......
<div id ="newsText">
<?php
foreach ($articles as $article){
for($articles=0; $articles <= count($articles); $articles++) {
$id = 1;
echo ("<p id =".$id++.">".$article['article_content']."</p>");
}
}
?>
</div>
您有任何错误消息吗?似乎你才开始使用jQuery。你是否按了F12来查看控制台上的javascript错误?
我尝试你的代码在[http://jsfiddle.net/w9AHt/][jsfiddle]它的工作很好,在onready事件,除了情况下,当幻灯片从最后一个更改到第一个
相关文章:
- Combine HTML5, CSS and JS
- JQuery, ajax and js OOP
- Combining HTML5, CSS and JS
- Asp.net and JS Error
- AJAX and JS for LIKE Button
- JSF, HighCharts and JS
- Aes encrypt .Net and Js
- Laravel minify css and js files
- html5 validation and JS
- NotePad++ and JS?
- CSV data and JS/HTML
- Arduino and JS/Cpp
- load the css and js
- ROR and JS debugging
- Symfony2 uglify CSS and JS
- jQuery UI Sortable and JS Cookie
- Websockets in python and js
- PHP and JS test
- Ajax and JS files
- Slider PHP, MYSQL and JS