我有一個腳本,隱藏頁面加載時顯示,當用戶關閉時隱藏。jQuery - 只應用到一頁的方法
我已經設置了這一點,以顯示每次用戶訪問該網站。但我只希望它適用於我的主頁。我不希望通知消息出現在網站的其他頁面上。
我使用WordPress,所以我無法編輯單個頁面的HTML。
jQuery('.header-notice a.close').click(function() {
jQuery('.header-notice').slideUp(200);
localStorage.setItem("notice", jQuery('.header-notice p').html());
return false;
});
if (localStorage.getItem("notice") === jQuery('.header-notice p').html()) {
jQuery('.header-notice').show();
}
jQuery('.alert .close').live('click', function() {
jQuery(this).parent('.alert').fadeOut(200);
return false;
});
WordPress使用了佔全部網頁的index.php? – BallSoHard 2013-03-12 17:37:52
嗯,只需使用標識您主頁的url部分,可以是'index.php?id = 40'或其他任何內容,如果您需要具體示例,請粘貼您的主頁網址。 – Nelson 2013-03-12 17:40:37