/    Sign up×
Community /Pin to ProfileBookmark

Why my javascript using jquery is not working ?

This is the code:

[CODE]<script type=’text/javascript’ src=”http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js”></script>
<script type=’text/javascript’ src=”http://vaakash.github.io/jquery/easy-ticker.js”></script>
<style>
.demof{
border: 1px solid #ccc;
margin: 25px 0;
}
.demof ul{
padding: 0;
list-style: none;
}
.demof li{
padding: 20px;
border-bottom: 1px dashed #ccc;
}
.demof li.odd{
background: #fafafa;
}
.demof li:after {
content: ”;
display: block;
clear: both;
}
.demof img{
float: left;
width: 100px;
margin: 5px 15px 0 0;
}
.demof a{
font-family: Arial, sans-serif;
font-size: 20px;
font-weight: bold;
color: #06f;
}
.demof p {
margin: 15px 0 0;
font-size: 14px;
}

.demo3 {
font-family: Arial, sans-serif;
border: 1px solid #C20;
margin: 50px 0;
font-style: italic;
position: relative;
padding: 0 0 0 110px;
box-shadow: 0 2px 5px -3px #000;
border-radius: 3px;
}
.demo3:before {
content: “Latest News”;
display: inline-block;
font-style: normal;
background: #C20;
padding: 10px;
color: #FFF;
font-weight: bold;
position: absolute;
top: 0;
left: 0;
}
.demo3:after {
content: ”;
display: block;
top: 0;
left: 80px;
background: linear-gradient(#FFF, rgba(255, 255, 255, 0));
height: 20px;
}
.demo3 ul li {
list-style: none;
padding: 10px 0;
}
</style>

<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=”demo3″ />’);
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>[/CODE]

If i will use only the script part it will work it will read line by line from the text file and scroll the lines up.
But now i want it to scroll each two lines inside the Latest News red box.
So i used this <style> tags.

This is the demo page the example of the red box with the Latest News:

[URL=”http://www.aakashweb.com/demos/jquery-easy-ticker/”]http://www.aakashweb.com/demos/jquery-easy-ticker/[/URL]

And this is what i see in my site :

[URL=”http://newsxpressmedia.com/test.html”]http://newsxpressmedia.com/test.html[/URL]

Iits not scrolling and i see all the text file content instead two lines each time.

I tried to replace in any place in my code from newsticker and newsTicker to demo3 but it didn’t work.

How can i make it work whats wrong with the code ?

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @Chocolade spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...