php - css + jQuery style.css switcher for new jQuery version -


i have been following kevin luck example of javascript css switcher. http://www.kelvinluck.com/assets/jquery/styleswitch/index.html

i got work on local projects. problem / question is, when use old javascript kevin luck uses, works. when try update jquery version, break. how can update example use newest 1.10.2 jquery?

the index page looks (relevant part)

<!doctype html> <html lang="en"> <head>     <meta charset="utf-8">     <title>public identity</title>      <link rel="stylesheet" type="text/css" href="css/collegestyles.css" title="college" media="screen" />     <link rel="alternate stylesheet" type="text/css" href="css/corporatestyles.css" title="corporate" media="screen" />      <!-- google cdn jquery -->     <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>     <!-- // <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> -->     <!-- css style switcher -->     <script type="text/javascript" src="styleswitch.js"></script> 

jquery (styleswitcher.js) looks this

/** * styleswitch stylesheet switcher built on jquery * under attribution, share alike license * 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 

the relevant css style sheet names, referred college , corporate. can see them in php / html code above. i'm pretty confused why break, , not sure how fix. ideas helpful. thanks!

change

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

to

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

from jquery documentation:

in jquery 1.3 [@attr] style selectors removed (they deprecated in jquery 1.2). remove “@” symbol selectors in order make them work again.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -