帮助!大声笑我不能弄明白! aaarrrghhhhjquery:如果url是____更改类
继承人我得到了什么
HTML:
<html xmlns="http://www.w3.org/1999/xhtml" class="bg1">
的Jquery:
$(document).ready(function(){
var identifier = window.location.pathname;
switch(identifier)
{
case: 'where-to-buy-our-goods.php';
$('html').removeClass('bg1').addClass('bg2');
break;
case: 'about.php';
$('html').removeClass('bg1').addClass('bg3');
break;
case: 'press.php';
$('html').removeClass('bg1').addClass('bg4');
break;
case: 'contact.php';
$('html').removeClass('bg1').addClass('bg5');
break;
}
});
也是我认为这可能有什么关系呢?
我的网站位于根目录下的文件夹中作为测试人员...
这样的URL是www.URL.com/Folder/about.php为exapmle ... IDK的,如果这改变了window.location.pathname应该是什么样子......
请帮助
有没有你不直接将这些类到你感兴趣的页面中的原因是什么?例如,在index.php上,添加一个将您的类设置为bg1的脚本。 – 2011-02-15 21:22:36
带有html和body标签的头文件是php包含的,所以它需要更具动态性,我认为 – Alex 2011-02-15 21:24:16