By: Nate

Updated 2 months ago

Source: http://trevordavis.net/

@Trevor-

I think if you say, “This is our list of $whatevers”, and you have an ordered list of items, the meaning of those items is the same as if they had an invisible #1-10 next to them. Whether that ranking means “best” or “worst” or “funniest” or whatever is, of course, subject to the nature of the content. But it makes me feel like it’s still well worth having the script reverse the actual items.

That said, there’s ...

  • 29 comments on this story
PRO

50% positive

Showing 26 relevant reactions out of 29.

Steward 2 months, 2 weeks ago on Wordpress

May be better without unnecessary variable “start”?

$(document).ready(function() {

$('.reversed').each(function() {

var $children = $(this).children('li');

var totalChildren = $children.length;

$children.each(function() {

$(this).val(totalChildren--);

});

});

});

I don’t understand –
... See all content

Reply

Trevor 2 months, 3 weeks ago on Wordpress

@Judd Lyon-

Thanks, I’m excited!

Reply

Judd Lyon 2 months, 3 weeks ago on Wordpress

Nice little trick, thanks!

Congrats on teaching and the new gig with Viget, they are an impressive outfit that just got better.

Cheers.

Reply

CSS Brigit | Reversed Ordered List with jQuery 2 months, 4 weeks ago on Wordpress

Reversed Ordered List with jQuery…

How to create an ordered list that counts in reverse with jQuery.

Reply

jquerybuzz 2 months, 4 weeks ago on Twitter

Reversed Ordered List with jQuery | Trevor Davis http://bit.ly/2DJNTf

Reply

palleman 2 months, 4 weeks ago on Twitter

Reversed Ordered List with jQuery: http://bit.ly/GSord #jQuery

Reply

Trevor 2 months, 4 weeks ago on Wordpress

@Nate-

Wow, thanks for running the performance tests. Your point about reversing the list items is certainly valid and a nice addition to the example.

Reply

Dave_Bush 2 months, 4 weeks ago on Twitter

New Link: Reversed Ordered List with jQuery | Trevor Davis: We are also going to add a class to the or.. http://bit.ly/49dbsW

Reply

Reversed Ordered List with jQuery | Trevor Davis 2 months, 4 weeks ago on Wordpress

[...] Reversed Ordered List with jQuery | Trevor Davis – [...]

Reply

44crosbyrow 2 months, 4 weeks ago on Twitter

Reversed Ordered List with jQuery | Trevor Davis http://bit.ly/1nPKr7

Reply

jQuery_Tips 3 months ago on Twitter

Reversed Ordered List with #jQuery http://bit.ly/3BqrAE

Reply

elijahmanor 3 months ago on Twitter

"Reversed Ordered List with jQuery" #tech #jquery http://j.mp/49KBpb

Reply

Nate 3 months ago on Wordpress

@Trevor-

I think if you say, “This is our list of $whatevers”, and you have an ordered list of items, the meaning of those items is the same as if they had an invisible #1-10 next to them. Whether that ranking means “best” or “worst” or “funniest” or whatever is, of course, subject to the nature of the content. But it makes me feel like it’s
... See all content

Reply

Trevor 3 months ago on Wordpress

@Nate-

Stupid WordPress.

Agreed, so I guess it just depends on whether there is a reference somewhere on the page saying that this list is presented in a certain order for a specific reason. If not, then I don’t think too much value is added in reversing it for non-JavaScript users.

I wonder what kind of load reversing the list adds to the page. I’m sure it’s
... See all content

Reply

Nate 3 months ago on Wordpress

@Nate-

Of course, by “unordered” above, I mean “ordered”.

Reply

Nate 3 months ago on Wordpress

I had <pre> tags, man: I think it was stripped out by your demon CMS. (Don’t be sad, WordPress, I didn’t mean it.)

I guess technically there’s nothing but order necessarily implied by an unordered list, but there are default ways, as far as browsers are concerned, of interpreting them, and the default is as a numbered list. In this instance, I think browsers behave
... See all content

Reply

Trevor 3 months ago on Wordpress

@Nate-

<pre tag sir…

I guess reordering the list does add some sort of semantic value, but how much really? It depends if there is any value given to item 10 vs. item 1.

Reply

Nate 3 months ago on Wordpress

Hmm — that code didn’t exactly format the way I would’ve liked. Help a brother out?

Reply

Nate 3 months ago on Wordpress

This is the sort of thing I mean:

This is number one.

This is number two.

This is number three.

This is number four.

$(document).ready(function() {

$('.reversed').each(function() {

var children = $(this).children('li').get();

$(this).empty();

children.reverse();

$(this).append(children);

$(children)
... See all content

Reply

Tweets that mention Reversed Ordered List with jQuery | Trevor Davis -- Topsy.com 3 months ago on Wordpress

[...] This post was mentioned on Twitter by Mike Lane, Dimox and Trevor Davis, Dimox. Dimox said: Reversed Ordered List with #jQuery – http://bit.ly/3aF6G2 [...]

Reply

mlane 3 months ago on Twitter

Reversed Ordered List with #jQuery - http://j.mp/1OFVq3

Reply

Dimox_ru 3 months ago on Twitter

Переворачиваем нумерованный список с помощью #jQuery - http://bit.ly/3aF6G2

Reply

Nate 3 months ago on Wordpress

I’d suggest, as an alternative, actually reordering the items in the list as well as adding values, so that the meaning that’s in the mark-up–that list of 1-10 items–is accurate, but simply presented in a different order than you’ll accomplish via javascript.

Reply

Nate 3 months ago on Wordpress

Sometimes it’s the simple things in life. One of the things I love about jQuery is finding out how effortless and straightforward it is to do deeply satisfying things like this to one’s code.

The only, very small, concern I have about this is that the meaning of the ordered list in so far as the mark-up is concerned is exactly opposite what you intend it to be. The javascript doesn’t
... See all content

Reply

Tom 3 months ago on Wordpress

Cool. Just in time for the end of year ‘best of’ lists to start up.

Reply

davist11 3 months ago on Twitter

Just wrote a short blog article about creating a reversed ordered list with jQuery http://bit.ly/4z4E5V

Reply

© uberVU Ltd. 2010

Terms of use