开发者

Adding User-specific classes dynamically

开发者 https://www.devze.com 2022-12-21 13:14 出处:网络
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:

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/
0

精彩评论

暂无评论...
验证码 换一张
取 消