Adding User-specific classes dynamically
I noticed that some wordpress themes ('Themat开发者_Go百科ic' for example) adds user specific classes to the body element so you don't have to retort to CSS browser hacks, for example:
wordpress y2010 m02 d26 h05 home singular slug-home page pageid-94 page-author-admin page-comments-open page-pings-open page-template page-template-home-php mac firefox ff3
So it automatically figured out the day, month, year, os, browser and browser version besides several other wordpress specific details and added them as classes to the body. Is it possible to do the same using jQuery only (no PHP) on static pages?
Thanks!
You could set an onload event on the body tag that calls a function that does something like this:
if($.browser.safari){
$('body').addClass("safari");
}
These links might help:
- http://docs.jquery.com/Utilities
- http://api.jquery.com/addClass/
精彩评论