this is my simple javascript function to switch colors and it works fine , but as far as i need to enable jquery or mootools in my website then its better to have this function modernized
function changeThemeColor(color)
{
switch(color)
{
case "style1":
default:
document.getElementById('CSSfile').href = 'css/style1.css';
setCookie('ThemeColor','style1',7);
break;
case "style2":
document.getElementById('CSSfile').href = 'css/style2.css';
setCookie('ThemeColor','style6',7);
break;
}
}
i know this maybe a huge quest but i really need to convert this code either into jquery or mootools
If your code works, why slow it down be converting it to library code that will just convert it back to what you have?
If this is actually what your code looks like, you could get rid of some of the redundancy:
The
style2is sending'style6'tosetCookie(). If that’s a mistake, and it should be sending'style2', you could further reduce it.