JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
<div id="myNewsticker">
<div id="newsNav"> <a href="#" id="prev"><img src="images/back.png"></a><a href="#" id="next"><img src="images/next.png"></a>
</div>
<div class="tickerLable">News:</div>
<div id="newsContent">
</div>
</div>
CSS
/***location of news ticker***/
#myNewsticker {
float: right;
margin-top: 20px;
margin-right: 8px;
width: 460px;
border-radius: 25px;
padding: 0 20px;
background: #851818;
color: white;
font-size: 14px;
font-family: calibri;
/*display: inline-block;*/
}
/*****newsTickerLable*******/
.tickerLable {
margin: 5px;
padding: 5px;
max-width: 38px;
}
/****hides all news ticker entries*****/
#myNewsticker .newsTicker {
display: none;
}
/****unhides the active ticker entry****/
#myNewsticker .newsTicker.active {
display: block;
}
/***location of news ticker content***/
.newsTicker {
margin-top: -32px;
padding: 5px;
max-width: 400px;
float: left;
margin-left: 60px;
}
/*****ticker navigation location***/
#newsNav {
padding-top: 3px;
width: 51px;
float: right;
margin-right: 15px;
margin-top: 3px;
}
/*****ticker navigation buttons******/
#prev img, #next img {
width: 25px;
/***changes size of images height and width****/
}
/*****popup window*****/
#pop_background {
position: fixed;
width: 100%;
height: 900px;
top: 0;
left: 0;
background: #000;
opacity: .8;
z-index: 1000;
cursor: pointer;
display: none;
}
#pop_box {
position: absolute;
background: #fff;
width: 30%;
margin: 100px 0 0 35%;
padding: 20px;
z-index: 1500;
display: none;
}
#close {
width: 30px;
height: 30px;
border-radius: 50%;
border: 1px solid #999;
text-align: center;
line-height: 30px;
font-size: 30px;
cursor: pointer;
float: right;
}
JavaScript
$(function () {
///////////////////////////////////////////////
$(document).ready(function () {
var newsChange, int
int = setInterval(newsChange, 3000);
$("#myNewsticker").mouseover(function(){
clearInterval(int);
});
$("#myNewsticker").mouseout(function(){
int = setInterval(newsChange, 3000);
});
function newsChange() {
var activeDiv = $("div.active");
activeDiv.removeClass("active").css("opacity", 0).animate({
opacity: 1
}, 800);
if (activeDiv.next().length === 0) {
$("div.newsTicker").eq(0).addClass("active").css("opacity", 0).animate({
opacity: 1
}, 800);
} else {
activeDiv.next().addClass("active").css("opacity", 0).animate({
opacity: 1
}, 800);
}
};
});
///////////////////////////////////////////////
$("#next").click(function () {
var activeDiv = $("div.active");
activeDiv.removeClass("active");
if (activeDiv.next().length === 0) {
$("div.newsTicker").eq(0).addClass("active").css("opacity", 0).animate({
opacity: 1
}, 800);
} else {
activeDiv.next().addClass("active").css("opacity", 0).animate({
opacity: 1
}, 800);
}
});
///////////////////////////////////////////////
$("#prev").click(function () {
var activeDiv = $("div.active");
activeDiv.removeClass("active");
if (activeDiv.prev().length === 0) {
$("div.newsTicker").eq(-1).addClass("active").css("opacity", 0).animate({
opacity: 1
}, 800);
} else {
activeDiv.prev().addClass("active").css("opacity", 0).animate({
opacity: 1
}, 800);
}
...