Page is a not externally linkable
JAB_Creations - 11:39 pm on Sep 8, 2011 (gmt 0)
The first problem is that you're using a framework which generates a ton of overhead and is completely unreliable by using proprietary methods such as innerHTML (and you won't know it until you reach a certain level which is difficult to achieve if you're using a framework to begin with). Stick to real JavaScript.
Here are a couple functions that I use to change the class of an element and to toggle the class of an element...
- John
Change Class
function change(id,newClass)
{
if (document.getElementById(id)) {document.getElementById(id).className=newClass;}
else if (id) {id.className=newClass;}
else {alert('Error: the id \''+id+'\' was not found or has not yet been imported to the DOM.\n\nNew class intended: '+newClass);}
}
// change('element_id','new_style');
// ||
// var s = document.getElementById('sidebar');
// change(s,'new_style');
Toggle Class
function change_toggle(id,c1,c2)
{
if (document.getElementById(id))
{
if (document.getElementById(id).className==c2) {change(id,c1);}
else {change(id,c2);}
}
else {alert('Error: the id \''+id+'\' was not found or has not yet been imported to the DOM.');}
}
//change_toggle('background_color_div','white','grey');