/    Sign up×
Community /Pin to ProfileBookmark

Javascript check if <li> is last subling and change class of all

Hi,

In my effort as a javascript newbie i’m trying to create a nothing too special progress bar. I’m this far that the li’s (bars) get a different color after another, but in the end it needs to change all bars back to the original class and start over. How do I accomplish this?

See [url]http://jsfiddle.net/6WQ2S/[/url]

Thanks!

to post a comment
JavaScript

10 Comments(s)

Copy linkTweet thisAlerts:
@KorMay 16.2011 — You should at least have specified that you are using JQuery ... I put that prefix for you.
Copy linkTweet thisAlerts:
@daanvhauthorMay 16.2011 — You should at least have specified that you are using JQuery ... I put that prefix for you.[/QUOTE]

I'm sorry for that. Thanks.
Copy linkTweet thisAlerts:
@daanvhauthorMay 18.2011 — anyone? I'm a total JS noob and been messing with this for hours ?
Copy linkTweet thisAlerts:
@KorMay 18.2011 — anyone? I'm a total JS noob and been messing with this for hours ?[/QUOTE]
If you are a total JS noob, you should have started by learning the JavaScript language before using JQuery. You can not be a surgeon before attending some classes and graduating from a Faculty of Medicine.
Copy linkTweet thisAlerts:
@daanvhauthorMay 18.2011 — If you are a total JS noob, you should have started by learning the JavaScript language before using JQuery. You can not be a surgeon before attending some classes and graduating from a Faculty of Medicine.[/QUOTE]

Please don't be hating because i'm new to this stuff. I only need these couple of lines to make it work, and I was on the assumption that guys here might wanna help me out.

It's not that i'm too lazy to figure it out myself, trust me, as a primarily webdesigner i've been breaking my head on this thing which is probably as easy as pie for you guys.

A solution that should be working is something with [CODE]if($(this).parent().next().length == 0) {[/CODE] but I just can't seem to get it work.
Copy linkTweet thisAlerts:
@KorMay 18.2011 — OK. Post a link to a test page, for us to see and test the whole picture. And be a little more descriptive. What, in fact, you need? ?

We might ask one of the Moderators here, which is JQuery expert, to help you, just in case.
Copy linkTweet thisAlerts:
@daanvhauthorMay 18.2011 — Thanks ?

The idea is really simple:

I need a progress bar, not linked to anything, which exists out of multiple div's that represent the bars, like this:

[URL=http://imageshack.us/photo/my-images/849/barol.jpg/][IMG]http://img849.imageshack.us/img849/1692/barol.jpg[/IMG][/URL]


To make it look like the loadingbar is filling up, each div have to change background-color one after another. I have got this all working, but when the last div (bar) has changed background-color, it just freezes, where instead, the script needs to change all div's back to the original css class (with the original bg color) and let the script start over again.

I put all the code and html and css in Fiddle, so you can test and change it for testing purposes, this seems to be more suitable than posting it on the forum itself?

http://jsfiddle.net/6WQ2S/ (great tool to test code btw!)

I hope this information is sufficient!
Copy linkTweet thisAlerts:
@KorMay 18.2011 — OK. Send a PM (a Personal Message) to Jeff Mott

http://www.webdeveloper.com/forum/member.php?u=8331

and kindly ask him to help you.

He's our JQuery expert here ?
Copy linkTweet thisAlerts:
@daanvhauthorMay 18.2011 — Wow you are awesome!

Much appreciated!
×

Success!

Help @daanvh 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.19,
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,
)...