幫助!大聲笑我不能弄明白! 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