Php css+;用于新jQuery版本的jQuery style.css切换器

Php css+;用于新jQuery版本的jQuery style.css切换器,php,javascript,jquery,css,styleswitching,Php,Javascript,Jquery,Css,Styleswitching,我一直在关注javascript css切换器的Kevin Luck示例。 我把它用于我的本地项目。 我的问题是,当我使用Kevin Luck使用的旧javascript时,它是有效的。 当我尝试更新jQuery版本时,它会崩溃。如何更新此示例以使用最新的1.10.2 jQuery 索引页如下所示(相关部分) 公众身份 jQuery(styleswitcher.js)如下所示 /** * Styleswitch stylesheet switcher built on jQuery * U

我一直在关注javascript css切换器的Kevin Luck示例。

我把它用于我的本地项目。 我的问题是,当我使用Kevin Luck使用的旧javascript时,它是有效的。 当我尝试更新jQuery版本时,它会崩溃。如何更新此示例以使用最新的1.10.2 jQuery

索引页如下所示(相关部分)


公众身份
jQuery(styleswitcher.js)如下所示

/**
* Styleswitch stylesheet switcher built on jQuery
* Under an Attribution, Share Alike License
* By Kelvin Luck ( http://www.kelvinluck.com/ )
**/

(function($)
{

    $(document).ready(function() {
        $('.styleswitch').click(function()
        {
            switchStylestyle(this.getAttribute("rel"));
            return false;
        });
        var c = readCookie('style');
        if (c) switchStylestyle(c);
    });

    function switchStylestyle(styleName)
    {
        $('link[@rel*=style][title]').each(function(i) 
        {
            this.disabled = true;
            if (this.getAttribute('title') == styleName) this.disabled = false;
        });
        createCookie('style', styleName, 365);
    }
})(jQuery);
// cookie functions http://www.quirksmode.org/js/cookies.html
function createCookie(name,value,days)
{
    if (days)
    {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name)
{
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++)
    {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}
function eraseCookie(name)
{
    createCookie(name,"",-1);
}
// /cookie functions
/**
*Styleswitch基于jQuery构建的样式表切换器
*在属性下,共享相同的许可证
*幸运的开尔文(http://www.kelvinluck.com/ )
**/
(函数($)
{
$(文档).ready(函数(){
$('.styleswitch')。单击(函数()
{
switchStylestyle(this.getAttribute(“rel”));
返回false;
});
var c=readCookie(“风格”);
if(c)switchStylestyle(c);
});
函数switchStylestyle(样式名)
{
$('link[@rel*=style][title]')。每个(函数(i)
{
this.disabled=true;
如果(this.getAttribute('title')==styleName)this.disabled=false;
});
createCookie('style',styleName,365);
}
})(jQuery);
//cookie函数http://www.quirksmode.org/js/cookies.html
函数createCookie(名称、值、天数)
{
如果(天)
{
变量日期=新日期();
date.setTime(date.getTime()+(天*24*60*60*1000));
var expires=“;expires=“+date.togmString();
}
else var expires=“”;
document.cookie=name+“=”+value+expires+“path=/”;
}
函数readCookie(名称)
{
变量nameEQ=name+“=”;
var ca=document.cookie.split(“;”);
对于(变量i=0;i
唯一相关的css是样式表名称,称为学院和公司。您可以在上面的php/html代码中看到它们。 我很困惑为什么会出现这种情况,也不知道如何修复。任何想法都会非常有用。 谢谢

变化

$('link[@rel*=style][title]').each(function(i) 

在jQuery 1.3中,删除了[@attr]样式选择器(它们是 以前在jQuery 1.2中已弃用)。只需删除“@”符号即可 从您的选择器,以使他们再次工作


控制台窗口中是否有任何错误?是的,未捕获错误:语法错误,无法识别的表达式:link[@rel*=style][title]jquery.js:1850 at.Error jquery.js:1850 mt jquery.js:2460 kt jquery.js:2847 at jquery.js:1289 x.fn.extend.find jquery.js:5730 x.fn.x.init jquery.js:197 x jquery.js:63 switchstyleswitch.js:22(匿名函数)styleswitch.js:17 c jquery.js:3048 p.fireWith jquery.js:3160 x.extend.ready jquery.js:433 qIt在我看来,它与这一行特别相关:$('link[@rel*=style][title]')。每个(函数(i)我试着删除@和*但是没有成功。那么,*做了什么呢?非常感谢!*是一个通配符选择器,它将匹配任何
链接
元素和
rel
属性包含“style”
$('link[@rel*=style][title]').each(function(i) 
$('link[rel*=style][title]').each(function(i)