Restoring cookie value and changing element style
1 answer
function getCookie(N){
if(N=(new RegExp(';\\s*'+N+'=([^;]*)')).exec(';'+document.cookie+';'))
return N[1]
}
we will use the above function to get the cookie value.
window.onload=function(){
var element, cookie = getCookie('yab_uploadmode');
if(cookie && (element = document.getElementById('btn'+cookie))){
//element.className = 'newClass'; // you can change the class...
element.style.color='red'; // ... or a single property
}
}
if you don't like using window.onload property use addEvent function .
+1
a source to share