/    Sign up×
Community /Pin to ProfileBookmark

hmm..childNodes not working in Firefox?

Can someone explain why this won’t work in Firefox?

[code=php]
<html>
<head>
<script type=”text/javascript”>
function run(count)
{
var list = document.getElementById(“ticker”).childNodes;
if(list[count-1])
{
list[count-1].style.display = “none”;
list[count-1].setAttribute(“display:none”);
}
else
{
list[list.length-1].style.display = “none”;
list[list.length-1].setAttribute(“display:none”);
}
list[count].style.display = “block”;
list[count].setAttribute(“display:block”);
count++;
if(count == list.length)
count = 0;
window.setTimeout(“run(” + count+ “)”,5000);
}
</script>
</head>
<body>
<div id=”ticker”><h3>This is an H3 element, it should still work!</h3><p>Test 1 – this is my first sentance, isn’t it a great sentance, it can be as long as you want it to be har har</p><p>Test 2 – this is my second sentance</p><p>Test 3 – this is my third sentance</p></div>
<script type=’text/javascript’>
run(0);
</script>
</body>
</html>
[/code]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@BigMoosieAug 26.2005 — Try this:
function run(count) {
var list=document.getElementById("ticker").childNodes, i=0, e;
while (e=list[i]) e.style.display=count==i++?"block":"none";
if(++count&gt;=list.length) count=0;
window.setTimeout("run("+count+")",1000);
}
×

Success!

Help @artfuljames 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.18,
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,
)...