How to add a class to body tag?

后端 未结 7 1023
猫巷女王i
猫巷女王i 2020-12-09 02:08

I want to add a class to a body tag with jQuery.

For example if the URL is http://www.mywebsite.com/about_us.asp, I want add the first five letters, in this case \'a

7条回答
  •  南笙
    南笙 (楼主)
    2020-12-09 02:14

    Well, you're going to want document.location. Do some sort of string manipulation on it (unless jQuery has a way to avoid that work for you) and then

    $(body).addClass(foo);
    

    I know this isn't the complete answer, but I assume you can work the rest out :)

提交回复
热议问题