How to add a CSS class to your WordPress lists with jQuery

How to add a CSS class to your WordPress lists with jQuery

How to add a CSS class to your WordPress lists with jQuery

css-menu

On this example, the static html code for menu use a dotted border on right for each menu item. The last menu item will have a special “li” class where the border is set to “none”, to can have the dotted separator just between two menu items.
[code='text']

[/code]

Ok, but this part of your code will look different when you are integrating it in WordPress for instance. Example:

[code='php']

[/code]

Now, the last menu item will have also the separator. If with “li” tag you can defines each item in the list, the “ul” tag defines the list. On WordPress, in this case, you cannot style a single item list without a small jQuery code inserted in your header.php

[code='js']
$(document).ready(function() {
$("#menu li:last").addClass("last");
});
[/code]

Now the menu look ok and on WordPress. You can apply in same way and a class for “first” list item.

About reADactor

Try to be a mixer of inspiration, source of tutorials, tips and a reactor of your future design ideas, a place from where you can download freebies, vectors and web templates. Follow us on Twitter and Facebook

View all posts

Network News

Feedbox

Share this!

Subscribe to our RSS feed. Tweet this! StumbleUpon Reddit Digg This! Bookmark on Delicious Share on Facebook
  1. [User Link:How to add a CSS class to your WordPress lists with jQuery] | Tips for Designers and Developers | tripwire magazine

  2. wp-popular.com » Blog Archive » How to add a CSS class to your WordPress lists with jQuery | reADactor

  3. 200 Fresh and Useful Articles for Designers and Developers | tripwire magazine

  4. How to add a CSS class to your WordPress lists with jQuery

  5. CSS Brigit | How to add a CSS class to your WordPress lists with jQuery

  6. 200+ Useful Resources for Graphics Designers and Web Developers | Graphics & Design | Online News & Entertainment

  7. April 3, 2011 at 1:43 pm

    WordPress is a powerful content management system but it doesn’t always do what you want it to do which is why help such as this is so invaluable. Many thanks.

  8. April 12, 2011 at 8:49 pm

    Thanks a lot for putting this code out there guys. I was searching for a way to do something very similar on my site and now I know that I can implement it. Cheers.

  9. April 14, 2011 at 8:10 am

    Adding this code will definitely make my wordpress lists more versatile. I will try this out for my own site. I’ll let you know soon if it works for me.

    Fred Homes
    Tucson architects

  10. May 31, 2011 at 1:56 pm

    Nice article.

    Just visit http://www.wordpressstop.com for lot of articles related to WordPress.

    Keep Smiling.

Leave a reply

*

*

Your email address will not be published. Required fields are marked *