Tuesday, May 20, 2008

jQuery is most excellet

I'm using jQuery for so many things nowadays (XML parsing, complicated style rules, flexible layout - the list goes on and on). Recently I had to style an ordered list so it would use numbers for the first level, lowercase alphabetical letters for the second level, and lowercase roman numerals for the third (much like an outline in MS Word). Whereas before I'd have to create CSS classes for this (icky), I instead do it via jQuery like so:

$("ol").css("list-style-type", "decimal");//First level; ordered lists default to this anyway
$("ol ol").css("list-style-type", "lower-alpha");//Second level, use lower-case alphabetical
$("ol ol ol").css("list-style-type", "lower-roman");//Third level, use lower-case Roman numeral
//I think you see the pattern
1. First level
a. Second level
i. Third level
2. First level
a. Second level
b. Second level
i. Third Level
ii. Third level
(I had to fake the demo as this particular site isn't using jQuery yet)

I realize that my regular readers could give a shit about this. My hope is that this will find it's way into a Google search as that is how I find all useful stuff on jQuery and I just want to pay it forward.

 

1 Comments:

Blogger Rachie said...

I love you, ya nerd! :o)

10:10 PM  

Post a Comment

<< Home

Previous Posts

Powered by Blogger


Warning: main(../includes/blog_include.php) [function.main]: failed to open stream: No such file or directory in /home/rafaelhe/public_html/blog/2008/05/jquery-is-most-excellet.php on line 186

Warning: main(../includes/blog_include.php) [function.main]: failed to open stream: No such file or directory in /home/rafaelhe/public_html/blog/2008/05/jquery-is-most-excellet.php on line 186

Warning: main() [function.include]: Failed opening '../includes/blog_include.php' for inclusion (include_path='/usr/lib/php:.:/usr/php4/lib/php:/usr/local/php4/lib/php') in /home/rafaelhe/public_html/blog/2008/05/jquery-is-most-excellet.php on line 186